Sha256: a62f9323e2a201f25a7e08b9330f589ea0a2c3911de7dab70aed5cd7c08ff598

Contents?: true

Size: 358 Bytes

Versions: 5

Compression:

Stored size: 358 Bytes

Contents

require 'singleton'

module OrElse
  class NothingClass < Maybe
    include Singleton

    def map
      Nothing
    end

    def flat_map
      Nothing
    end

    def empty?
      true
    end

    def nil?
      empty?
    end

    def exists?
      !empty?
    end

    def or_else
      yield
    end
  end
end

Nothing = OrElse::NothingClass.instance

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
or_else-0.0.5 lib/or_else/nothing_class.rb
or_else-0.0.4 lib/or_else/nothing_class.rb
or_else-0.0.3 lib/or_else/nothing_class.rb
or_else-0.0.2 lib/or_else/nothing_class.rb
or_else-0.0.1 lib/or_else/nothing_class.rb