From: David Alan Black Date: 2001-12-01T02:38:12+09:00 Subject: [ruby-talk:27095] Re: Using Enumerable Hi -- On Sat, 1 Dec 2001, Matt Armstrong wrote: > David Alan Black writes: > > > Or even: > > > > def each > > yield *@pointer + 1 .. @end > > end > > What is going on with this code? I can't figure it out. Whoops, I guess I crossed the line :-) Here's what's going on: @pointer + 1 .. @end is a range. If you yield a range: yield @pointer + 1 .. @end the result is that you've only yielded one thing -- namely, a range. So instead of yielding 1, then 2, then 3.... you'd just yield (0..10). However, the asterisk breaks the range out into its elements. Compare: p 1..5 # prints: 1..5 p *1..5 # prints: 1 2 3 4 5 So... yield *(some range) is shorthand for yielding each element of the range separately. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav