From: Jamey Cribbs Date: 2005-08-20T22:07:03+09:00 Subject: Re: Python vs Ruby! Devin Mullins wrote: > Jamey Cribbs wrote: > >> def select(&select_cond) >> result = [] >> @db.engine.get_recs(self).each do |rec| >> result << rec if select_cond.call(rec) end >> return result >> end > > > Why not: > def select > result = [] > @db.engine.get_recs(self).each { |rec| result << rec if yield rec } > result > end > > Or if get_recs returns an Enumerable: > def select(&select_cond) > @db.engine.get_recs(self).select(&select_cond) > end > > Or if not: > def select(&select_cond) #this is probably not very performant > @db.engine.get_recs(self).extend(Enumerable).select(&select_cond) > end > Well, it's like I said in my original post, this was an example of a *greatly* simplified #select method in KirbyBase. In the actual method, there's a *lot* more going on. :-) Jamey