From: Ezra Zygmuntowicz Date: 2007-07-12T06:35:36+09:00 Subject: Re: Returning part of a hash On Jul 11, 2007, at 2:27 PM, Craig Demyanovich wrote: >> class Hash >> # lets through the keys in the argument >> # >> {:one => 1, :two => 2, :three => 3}.pass(:one) >> # => {:one=>1} >> def pass(*keys) >> self.reject { |k,v| ! keys.include?(k) } >> end >> >> # blocks the keys in the arguments >> # >> {:one => 1, :two => 2, :three => 3}.block(:one) >> # => {:two=>2, :three=>3} >> def block(*keys) >> self.reject { |k,v| keys.include?(k) } >> end >> >> end > > > Ezra, > > Since you're adding the #pass and #block methods to Hash and Hash > already > has a #keys method, is there a conflict between the *keys parameter > to #pass > and #block and the #keys method on Hash? > > Thanks, > Craig There is not a conflict as it does do what's advertised, but it's probably a good idea to change the name anyways, thanks for pointing that out. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)