Never mind. Ignore. Wrong. See Guy D.'s message. My code was working by coincidence -- I had a #puts in the block which made it seem like each element of the range was being handled separately, when in fact it was just puts'ing an array. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav On Sat, 1 Dec 2001, David Alan Black wrote: > Hi -- > > On Sat, 1 Dec 2001, Matt Armstrong wrote: > > > David Alan Black <dblack / candle.superlink.net> 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 >