Module: Kind::Maybe

Extended by:
Maybe
Included in:
Maybe
Defined in:
lib/kind/maybe.rb,
lib/kind/maybe/none.rb,
lib/kind/maybe/some.rb,
lib/kind/maybe/monad.rb,
lib/kind/maybe/typed.rb,
lib/kind/maybe/wrapper.rb

Defined Under Namespace

Modules: Buildable, Methods Classes: Monad, None, Some, Typed

Constant Summary collapse

NONE_INSTANCE =
None.new(nil)

Instance Method Summary collapse

Instance Method Details

#new(value) ⇒ Object Also known as: []



16
17
18
19
# File 'lib/kind/maybe.rb', line 16

def new(value)
  (::Exception === value || KIND.nil_or_undefined?(value) ? None : Some)
    .new(value)
end