Sha256: 0ba5d1723854cc745d59fd352fec55eb638c56424b806fa324ee5796e128abc5

Contents?: true

Size: 567 Bytes

Versions: 8

Compression:

Stored size: 567 Bytes

Contents

# frozen_string_literal: true

module Kind
  class Either::Left < Either::Monad
    def left?
      true
    end

    def value_or(default = UNDEFINED, &block)
      Error.invalid_default_arg! if UNDEFINED == default && !block

      UNDEFINED != default ? default : block.call(value)
    end

    def map(&_)
      self
    end

    alias_method :map!, :map
    alias_method :then, :map
    alias_method :then!, :map
    alias_method :and_then, :map
    alias_method :and_then!, :map

    def inspect
      '#<%s value=%p>' % ['Kind::Left', value]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kind-5.10.0 lib/kind/either/left.rb
kind-5.9.0 lib/kind/either/left.rb
kind-5.8.1 lib/kind/either/left.rb
kind-5.8.0 lib/kind/either/left.rb
kind-5.7.0 lib/kind/either/left.rb
kind-5.6.0 lib/kind/either/left.rb
kind-5.5.0 lib/kind/either/left.rb
kind-5.4.1 lib/kind/either/left.rb