From: dblack@... Date: 2006-01-03T06:22:56+09:00 Subject: Re: New to Ruby and Programming Hi -- On Tue, 3 Jan 2006, Hal Fulton wrote: > James Edward Gray II wrote: >> On Jan 2, 2006, at 2:08 PM, Hal Fulton wrote: >> >>> Chad Perrin wrote: >>> >>>> On Tue, Jan 03, 2006 at 12:03:03AM +0900, James Edward Gray II wrote: >>>> >>>>> On Jan 2, 2006, at 2:29 AM, Chad Perrin wrote: >>>>> >>>>> >>>>>> In particular, you could have an array called myarray >>>>>> (for example) and iterate over its contents using the each method to >>>>>> perform the same action on each element of the array: >>>>>> >>>>>> myarray.each do { |foo| puts foo } >>>>> >>>>> >>>>> Only we would never write that since the following does the same thing: >>>>> >>>>> puts myarray >>>> >>>> Well . . . true. >>>> This is why I don't teach programming. >>> >>> >>> Actually, I think there's a difference in behavior >>> if you try them both. >> >> >> Other than the return value? > > Well, I'm quite wrong. I thought that 'puts myarray' would print > on a single line with elements scrunched together. Maybe this > was true in the past? I think what you're thinking of is array.to_s, which scrunches them together. But puts array does a separate puts on each element. David -- David A. Black dblack@wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black