Sha256: cf1c0cdc6bd67c84458168527fd3fe819abf8520f6132246ef9fa4780f6b415b

Contents?: true

Size: 739 Bytes

Versions: 4

Compression:

Stored size: 739 Bytes

Contents

require 'singleton'

module Monad
  module Maybe
    class Nothing < Base
      include ::Singleton
  
      def method_missing(method, *args)
        self
      end
  
      def clone
        self
      end
  
      def inspect
        'nothing'
      end
  
      def nil?
        true
      end
  
      def nothing?
        true
      end
  
      def bind(fn)
        self
      end

      def just?
        false
      end

      def something?
        false
      end
  
      def unwrap(val)
        val
      end
  
      def value
        nil
      end
  
      def to_s
        ''
      end
      alias to_str to_s

      def to_a
        []
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
monad-maybe-0.9.8 lib/monad/maybe/nothing.rb
monad-maybe-0.9.7 lib/monad/maybe/nothing.rb
monad-maybe-0.9.5 lib/monad/maybe/nothing.rb
monad-maybe-0.9.4 lib/monad/maybe/nothing.rb