Class: Unsound::Data::Just
Instance Method Summary collapse
-
#>>(f = nil, &blk) ⇒ Data::Nothing, Data::Just
(also: #and_then)
Chain another operation which can result in a Maybe.
-
#fmap(f = nil, &blk) ⇒ Data::Just
Apply a function to a value contained in a Just.
-
#or_else ⇒ Data::Just
A Noop.
Methods inherited from Maybe
Instance Method Details
#>>(f = nil, &blk) ⇒ Data::Nothing, Data::Just Also known as: and_then
Chain another operation which can result in a Maybe
74 75 76 |
# File 'lib/unsound/data/maybe.rb', line 74 def >>(f = nil, &blk) (f || blk)[value] end |
#fmap(f = nil, &blk) ⇒ Data::Just
Apply a function to a value contained in a Unsound::Data::Just
66 67 68 |
# File 'lib/unsound/data/maybe.rb', line 66 def fmap(f = nil, &blk) self >> Composition.compose(method(:of), (f || blk)) end |
#or_else ⇒ Data::Just
A Noop
82 83 84 |
# File 'lib/unsound/data/maybe.rb', line 82 def or_else(*) self end |