Class: Many

Inherits:
Struct show all
Includes:
Monad
Defined in:
lib/maybe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Monad

#within

Instance Attribute Details

#valuesObject

Returns the value of attribute values

Returns:

  • (Object)

    the current value of values



37
38
39
# File 'lib/maybe.rb', line 37

def values
  @values
end

Instance Method Details

#and_then(&block) ⇒ Object



38
39
40
41
42
# File 'lib/maybe.rb', line 38

def and_then(&block)
  Many.new(
    values.map(&block).flat_map(&:values)
  )
end