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.
-
#maybe(f, _) ⇒ Object
Call a function on the value in the 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
83 84 85 |
# File 'lib/unsound/data/maybe.rb', line 83 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
75 76 77 |
# File 'lib/unsound/data/maybe.rb', line 75 def fmap(f = nil, &blk) self >> Composition.compose(method(:of), (f || blk)) end |
#maybe(f, _) ⇒ Object
Call a function on the value in the Unsound::Data::Just
99 100 101 |
# File 'lib/unsound/data/maybe.rb', line 99 def maybe(f, _) f[value] end |
#or_else ⇒ Data::Just
A Noop
91 92 93 |
# File 'lib/unsound/data/maybe.rb', line 91 def or_else(*) self end |