Method: Immutable::Set#each

Defined in:
lib/immutable/set.rb

#each {|item| ... } ⇒ self, Enumerator

Call the block once for each item in this Set. No specific iteration order is guaranteed, but the order will be stable for any particular Set. If no block is given, an Enumerator is returned instead.

Examples:

Immutable::Set["Dog", "Elephant", "Lion"].each { |e| puts e }
Elephant
Dog
Lion
# => Immutable::Set["Dog", "Elephant", "Lion"]

Yields:

  • (item)

    Once for each item.

Returns:

  • (self, Enumerator)


163
164
165
166
167
# File 'lib/immutable/set.rb', line 163

def each
  return to_enum if not block_given?
  @trie.each { |key, _| yield(key) }
  self
end