Stefano Crocco
9/11/2008 8:17:00 AM
On Thursday 11 September 2008, Mischa Fierer wrote:
> Hello,
>
> The following makes sense to me:
>
> lambda {|x| puts x; [1,2].collect{|x| x+1} }.call("aaa")
> aaa
> => [2, 3]
>
> The following does not so much:
>
> lambda {|x| puts x; [1,2].collect{|x| x+1}; puts x }.call("aaa")
> aaa
> 2
> => nil
>
> Why is the final puts x not return a?
Because puts always returns nil:
ri IO#puts
---------------------------------------------------------------- IO#puts
ios.puts(obj, ...) => nil
------------------------------------------------------------------------
Stefano