File: select.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (17 lines) | stat: -rw-r--r-- 261 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Hash

  unless method_defined?(:select!)

    # In-place version of Hash#select.  The opposite of the built-in
    # Hash#reject!.
    #
    # CREDIT: Gavin Sinclair, Noah Gibbs

    def select!
      reject! { |k,v| not yield(k,v) }
    end

  end

end