class Nothing

Nothing is a member of the Maybe union type that represents a null value. It's used in conjunction with the Just type to allow one to gracefully handle null values without having to create a large amount of conditional logic.

Constants

C
NothingError

Public Class Methods

instance() click to toggle source
# File lib/maybe.rb, line 192
def self.instance
  @instance ||= new
end

Public Instance Methods

==(m) click to toggle source
# File lib/maybe.rb, line 302
def ==(m)
  m.is_a?(Nothing)
end
ap(m) click to toggle source
# File lib/maybe.rb, line 288
def ap(m)
  self
end
Also aliased as: apply
apply(m)
Alias for: ap
flat_map(&f) click to toggle source
# File lib/maybe.rb, line 275
def flat_map(&f)
  self
end
get() click to toggle source
# File lib/maybe.rb, line 207
def get
  raise NothingError, "cannot get the value of Nothing."
end
get_or_else(&f) click to toggle source
# File lib/maybe.rb, line 222
def get_or_else(&f)
  f.call
end
inspect() click to toggle source
# File lib/maybe.rb, line 314
def inspect
  "Nothing"
end
just?() click to toggle source
# File lib/maybe.rb, line 230
def just?
  false
end
map(&f) click to toggle source
# File lib/maybe.rb, line 256
def map(&f)
  self
end
nothing?() click to toggle source
# File lib/maybe.rb, line 238
def nothing?
  true
end