From: Ken Bloom Date: 2009-01-14T10:39:12+09:00 Subject: Re: Implementing each and <=> On Tue, 13 Jan 2009 14:15:58 -0500, Ruby Rabbit wrote: > badboy wrote: >> Ruby Rabbit schrieb: >>> >>> (let's just assume that @list is an array) >>> >>> Thanks. >> i would define each like this: >> def each(&blk) >> @list.each(&blk) >> end > > okay, i forgot to mention that I was wondering whether the > easiest/cleanest way was to use a send somehow? > > def each > @list.send > end No. This won't work. Send is just a method for calling methods, and unless you pass it a method name and all relevant arguments, it won't know what message to send. Thus, you'll be at def each &blk @list.send :each, &blk end and it's easier to do def each &blk @list.each &blk end --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/