Method: Immutable::Set#map

Defined in:
lib/immutable/_core.rb

#map {|item| ... } ⇒ Set Also known as: collect

Call the block once for each item in this Set. All the values returned from the block will be gathered into a new Set. If no block is given, an Enumerator is returned instead.

Examples:

Immutable::Set["Cat", "Elephant", "Dog", "Lion"].map { |e| e.size }
# => Immutable::Set[8, 4, 3]

Yields:

  • (item)

    Once for each item.

Returns:



2697
2698
2699
2700
2701
# File 'lib/immutable/_core.rb', line 2697

def map
  return enum_for(:map) if not block_given?
  return self if empty?
  self.class.new(super)
end