Method: Funkr::Types::Maybe#bind

Defined in:
lib/funkr/types/maybe.rb

#bind(&block) ⇒ Object



103
104
105
106
107
108
109
110
111
112
# File 'lib/funkr/types/maybe.rb', line 103

def bind(&block)
  # This implementation isn't safe but is a bit faster than the
  # safe one. A safe implementation would be as follow :
  #   self.match do |on|
  #     on.just {|v| yield(v)}
  #     on.nothing {self}
  #   end
  if self.just? then yield(self.unsafe_content)
  else self end
end