lib/core/facets/enumerable/occur.rb in facets-2.4.5 vs lib/core/facets/enumerable/occur.rb in facets-2.5.0
- old
+ new
@@ -11,11 +11,9 @@
# [1,2,2,3,3,3].occur(2..3) #=> [2,3]
#
# [1,1,2,3,3,4,5,5].occur { |n| n == 1 } #=> [2,4]
# [1,1,2,3,3,4,5,5].occur { |n| n > 1 } #=> [1,3,5]
#
- # CREDIT: ?
-
def occur(n=nil) #:yield:
result = Hash.new { |hash, key| hash[key] = Array.new }
self.each do |item|
key = item
result[key] << item