Sha256: 5bea455c0fee51b13716b067ef4228ce8ab953428705061573220a513093ad11

Contents?: true

Size: 366 Bytes

Versions: 1

Compression:

Stored size: 366 Bytes

Contents

module OrElse
  class Just < Maybe

    attr_reader :value

    def initialize(val)
      @value = val
    end

    def map
      Maybe(yield value)
    end

    def flat_map
      yield value
    end

    def empty?
      false
    end

    def exists?
      !empty?
    end

    def or_else
      value
    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.3 lib/or_else/just.rb