Hi Fily

2011/4/27 Fily Salas <fs_tigre / hotmail.com>:
> Hi,
>
> I was practicing ruby and accidentally came across something that got me
> thinking (nothing important but I want to know why).
>
> Why does the example-1 works and not example-2, if all I'm doing is
> moving the puts?
>
> Example-1:
> def message
> "this is working"
> end
> puts message.upcase
>
>
> Example-2:
> def message
> puts "this is working"
> end
> message.upcase
>
> Can someone explain this a little bit? I could just ignore it but I
> would like to know the reason.

The return value of the "puts" method is always nil, not the string it
prints. What your second example does is try to invoke the "upcase"
method on nil.

-- 
Roger Braun
rbraun.net | humoralpathologie.de