Sha256: a3079cdd0396960dbd50d94456dd4b7f2e565bdb686f1c0c75d56c4215f81422
Contents?: true
Size: 486 Bytes
Versions: 4
Compression:
Stored size: 486 Bytes
Contents
unless (RUBY_VERSION[0,3] == '1.9') module Enumerable # Count the number of items in an enumerable # equal (==) to the given object. # # e = [ 'a', '1', 'a' ] # e.count('1') #=> 1 # e.count('a') #=> 2 # # Count can also handle multiple-valued blocks. # # e = { 'a' => 2, 'a' => 2, 'b' => 1 } # e.count('a',2) #=> 1 # # CREDIT: Trans def count(*c) self.select{ |*i| i == c }.length end end end
Version data entries
4 entries across 4 versions & 1 rubygems