Making a wild guess at the signal in the noise.

On Mon, 19 Feb 2007 13:44:46 +0100, Derek Teixeira  
<derek.teixeira / gmail.com> wrote:
> Along with that confusion on the return function.. i was code tracing
> the code below and i understand it, except for one part, i just don't
> see where the code tells the program to print out the numString. I see
> it telling the program to in the 'one hundred' section, but not at all
> in the teens or single digits?
>
> [snip self-depreciation - just keep that one out next time ;P]
>
> def englishNumber number
>   ## [snip unrelated code]
>
>   #  If we got this far, then we had a number somewhere
>   #  in between 0 and 100, so we need to return "numString".
>   numString ## equivalent to "return numString"
> end
>

In Ruby, a function always returns the value of the last expression in its  
definition by default if it reaches the end.

(I really, really, really hate on relying on this behaviour because it  
makes it easy to miss the fact that this is happening instead of just a  
"void" method call, or to miss that the method is in fact returning  
anything at all, and it really doesn't belong in a beginners' book. Tut.  
Oversight maybe?)

David Vallner