Sha256: 0d77d67624940d7d37e867feeef4dff3c6d266f72c1ae4d777998d284100ef17

Contents?: true

Size: 368 Bytes

Versions: 1

Compression:

Stored size: 368 Bytes

Contents

module OrElse
  class Just < Maybe

    attr_reader :value

    def initialize(val)
      @value = val
    end

    def map
      yield Just.new(value)
    end

    def flat_map
      yield value
    end

    def empty?
      false
    end

    def exists?
      !empty?
    end

    def or_else
      self
    end
  end
end

def Just(val)
  OrElse::Just.new(val)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
or_else-0.0.1 lib/or_else/just.rb