Method: Multiset#each
- Defined in:
- lib/multiset.rb
#each ⇒ Object
Calls the given block once for each element in the set, passing the element as parameter. Returns an enumerator if no block is given.
69 70 71 72 73 74 75 76 |
# File 'lib/multiset.rb', line 69 def each @hash.each_pair do |key, multiplicity| multiplicity.times do yield(key) end end self end |