1. If you aren’t really sure what return does, try writing a few of your own functions and have them return some values. You canr eturn anything that you can put to the right of an =.
2. At the end of the script is a puzzle, I’m taking the return value of one function and using it as the argument of another function. I’m doing this in a chain so that I’m kind of creating a forumla using the functions. It looks really weird, but if you run the script you can see the results. What you should do is try to figure out the normal formula that would recreate this same set of operations.
Done. Not exactly the same, but I’ve made my own exercise.
3. Once you have the formula worked out for the puzzle, get in there and see what happens when you modify the part of the functions. Try to change it on purpose to make another value.
4. Do the inverse. Write a simple formula and use the functions to do the same way to calculate it.
So much math….
5. Removed the word return and see if the script still works. You’ll find that it does because Ruby implicitly returns whatever the last expression calculates. However, this isn’t clear so I want you to do it explicitly for my book.