You can improve
plural to work correctly with more words. If the project is not already open,
please reload it. (The suggested file name was
listof the words you want it to work for.
pluralblock should never give words to
plural-hunless those words end with h.
mapto test it on the entire
listyou made earlier.
Abstraction: Language often has special cases. In English, the plurals of some
add s; some add es; nouns like calf and fly become
calves and flies, changing their final letters before adding es. And
more. For a programming task this complex, it's (generally) best to break it into parts, handle
part separately with its own procedure (its own block), and then have the "top-level" block—in
plural, itself—use those specialists. That is, instead of coding every little
detail directly in
plural, it is cleaner and clearer to make
something like this.
Showing the structure of the method—just the overall strategy—in the "top-level" block and leaving the details to separate blocks is one part of an important computer science idea called abstraction. Abstraction keeps your code clear, readable, and more easily debugged. It will also help your code be more flexible.
pluralto use the specialist. Test (you can use
map) to make sure
pluralstill works for all the words it used to work for, as well as the new ones.
plural-yto handle words like and
Remember, any specialist can make mistakes if it's asked to do a job that isn't its specialty.
plural gives it only the job it knows how to handle correctly.
pluralto handle another special case. Use a special-purpose block for your special case to keep
pluralfrom becoming cluttered.
pluralis given a word with a space at the end, it leaves that space in the plural, like this: . You already have a block that specializes in making plurals of words that don't have a space at the end. Use it.
pluralworks for a single space at the end of a word, try giving it . That works!! But why?!