Class: Monadt::Present

Inherits:
Object
  • Object
show all
Defined in:
lib/monadt/maybe.rb

Overview

like Maybe but nil / not-nill

Class Method Summary collapse

Class Method Details

.bind(m, &blk) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/monadt/maybe.rb', line 27

def bind(m, &blk)
  if m.nil?
    nil
  else
    blk.call(m)
  end
end

.return(a) ⇒ Object



35
36
37
# File 'lib/monadt/maybe.rb', line 35

def return(a)
  a
end