Re: rough first impressions

"Steven Shaw" <[email protected]> Wed, 16 Apr 2003 00:00:11 +1000
Newsgroups gmane.comp.lang.goo.general
Message-ID <001b01c30357$62308190$e52a86cb@z>
> I haven't programmed very much Ruby, but looking at the Ruby book it
> seems like its iterators are mostly just sugar for higher-order
> functions -- the "yield" keyword lets you pass a function as an
> implicit argument to a method -- ie, you just write
>
>   foo(x) {|n| n + n}
>
> rather than
>
>   foo(x, {|n| n + n })

That's exactly right. Python's yield statement is more powerful and must be
encoded as a coroutinue in the the most general case. However, Ruby does
have full continuations so something resembling Python iterators could be
put together as a library. I'm not sure whether that's a common idiom in
Ruby, though.