From: David Alan Black Date: 2001-11-29T23:16:25+09:00 Subject: [ruby-talk:26898] Re: short article draft for review Hi -- A couple o' suggestions: On Thu, 29 Nov 2001, Tobias Reif wrote: > Iterators: > > for first in 1..2 do > for second in 1..3 do > puts first.to_s + '.' + second.to_s > end > end To me, that doesn't illustrate iterator power very dramatically or clearly. I guess it's iterating... but when I think of a Ruby iterator, I think of a method that iterates over something and "yield"s to a block. Well, maybe that's what the range is doing... but you're putting the focus on the "for" structure. > Recursion, blocks as arguments: > > def upto limit,current=1,&block > yield current > if current < limit > upto limit,current+=1,&block > end > end > > upto(2) do |integer| > puts 'line' + integer.to_s > end Yeah, like that :-) My advice would be to include an example that involves an interator (without recursion), and then, if you think it's important, a recursion example. One other thing: In method definitions, putting the arg list in parens might be a good idea. (Personally I dislike the non-paren look, but here I'm thinking of people who might like it ultimately but might be confused by it initially.) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav