From: Devin Mullins Date: 2005-08-20T06:02:52+09:00 Subject: Re: Python vs Ruby! 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 Sorry, can't help it, it's like a tic. YMMV. Kirk Haines wrote: >I *heart* that sort of query syntax. You'll see much the same thing in the >Kansas ORM: > >results = ksdbh.select(:Planes) {|r| (r.country == 'USA') & (r.speed > 350)} > >In this case, method_missing magic is mixed into that in such a way that the >Ruby code becomes a SQL statement for querying a relational database. > > That is awesome, and my hat is off to you. Devin