From: dblack@... Date: 2003-03-25T04:44:14+09:00 Subject: Re: [puts] - bug or feature? Hi -- On Tue, 25 Mar 2003, Meinrad Recheis wrote: > hi ruby community, > > i wrote a ruby script and executed it, here are the lines and the results: > puts 3.to_s + 'b' # => 3b 3.to_s == "3", to which you add 'b', and then you print the whole result ("3b"). So it's like: puts ((3.to_s) + 'b') > puts (3).to_s + 'b' # => 3 This calls puts(3), the return value of which is nil. nil.to_s is "", which gets added to 'b'. You haven't asked it to print that result, so it just gets discarded. (But that's why you get "b" as the expression's value when you do the same expression in irb.) So that one is like: ((puts 3).to_s) + 'b' > puts ((3).to_s + 'b') # => 3b Here you're evaluating the expression and *then* printing it, including the 'b'. David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav