module Option

Constants

C
Func1toOption
NoneType
OptionType

Public Class Methods

all(array_of_options) click to toggle source
# File lib/trither/option.rb, line 27
def self.all(array_of_options)
  array_of_options.reduce(Some.new([])) do |memo, option|
    memo.flat_map do |array|
      option.map { |value| array + [value] }
    end
  end
end
flatten(array_of_options) click to toggle source
# File lib/trither/option.rb, line 36
def self.flatten(array_of_options)
  array_of_options.reduce([]) do |array, option|
    if option.empty?
      array
    else
      array + [option.get_or_else { raise StandardError }]
    end
  end
end
make(value) click to toggle source
# File lib/trither/option.rb, line 18
def self.make(value)
  if value.nil?
    None
  else
    Some.new(value)
  end
end