From: Ken Bloom Date: 2008-03-08T00:39:54+09:00 Subject: Re: Erratic result On Thu, 06 Mar 2008 03:49:13 -0500, coolgeng coolgeng wrote: > [Note: parts of this message were removed to make it a legal post.] > > Hi > I do not know how to explain the different result between the two > snippets: > def dial(digit) > puts digit end > digits = 0..9 > puts digits.each {|digit| dial(digit) } It's that extra puts before digits.each By convention, #each returns self, so after using dial to call puts for each individual digit, you also call puts on the return value of digits.each, which is digits itself. puts calls #to_s on digits, which for a Range gives you the source code representation of the range. --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/