From: Rodrigo Rosenfeld Rosas Date: 2012-04-14T03:16:59+09:00 Subject: [ruby-core:44343] Has Hash#slice inclusion already been discussed in bugs.ruby-lang.org? This is a multi-part message in MIME format. --------------090008050408030005040400 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit I find this method very useful: http://as.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Slice.html I don't mean its exact implementation, but it would be a short-hand to: def slice(*keys) select {|k, v| keys.include? k} # talking about the idea only, not performance end Or maybe it could be defined as having a little bit different output when the keys are not found in the original hash: def slice(*keys) keys.each_with_object({}){|k, h| h[k] = self[k] } # of course, this is a simplification as the initial object should use the same default/default_proc end Sorry, but I couldn't find any references to any issue discussing this. If this has been already discussed, could you please point me to the original issue discussion? Cheers, Rodrigo. --------------090008050408030005040400 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I find this method very useful:

http://as.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Hash/Slice.html

I don't mean its exact implementation, but it would be a short-hand to:

def slice(*keys)
  select {|k, v| keys.include? k} # talking about the idea only, not performance
end

Or maybe it could be defined as having a little bit different output when the keys are not found in the original hash:

def slice(*keys)
    keys.each_with_object({}){|k, h| h[k] = self[k] } # of course, this is a simplification as the initial object should use the same default/default_proc
end

Sorry, but I couldn't find any references to any issue discussing this.

If this has been already discussed, could you please point me to the original issue discussion?

Cheers,
Rodrigo.
--------------090008050408030005040400--