~ubuntu-branches/ubuntu/trusty/ruby-facets/trusty

« back to all changes in this revision

Viewing changes to src/core/facets/hash/select.rb

  • Committer: Package Import Robot
  • Author(s): Marc Dequènes (Duck)
  • Date: 2012-01-03 03:35:44 UTC
  • Revision ID: package-import@ubuntu.com-20120103033544-pq0yyio1675gfgw6
Tags: upstream-2.9.2
Import upstream version 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class Hash
 
2
 
 
3
  unless method_defined?(:select!)
 
4
 
 
5
    # In-place version of Hash#select.  The opposite of the built-in
 
6
    # Hash#reject!.
 
7
    #
 
8
    # CREDIT: Gavin Sinclair, Noah Gibbs
 
9
 
 
10
    def select!
 
11
      reject! { |k,v| not yield(k,v) }
 
12
    end
 
13
 
 
14
  end
 
15
 
 
16
end
 
17