Sha256: 2c59e518dc8f69aefbadc3603fd2166eb00d303167f014ab317e3486a342a1e7

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

# :title: NilClass as Emptiness/Nothingness
#
# The ideas here is to have nil act more like
# an empty set than an error catcher.
# So you get responses like
#
#   nil.include?(:x) # => nil
#
# instead of an error being raised.
#
# WARNING! One should be aware that in some rare cases
# incompatabilites may arise when using these methods in
# conjuction with other libraries.

require 'nano/nilclass/to_f'
require 'nano/nilclass/to_h'
require 'nano/nilclass/op_fetch'
require 'nano/nilclass/include'
require 'nano/nilclass/empty'
require 'nano/nilclass/size'
#require 'nano/nilclass/length'

# For the most part the following is what's happening:
#
# class NilClass
#   def to_f; 0.0; end
#   def to_h; {}; end
#   def size; 0; end
#   def length; 0; end
#   def empty?; true; end
#   def [](*args); nil; end
#   def include?(*args); nil; end
# end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
facets-0.9.0 lib/nano/nil_as_emptiness.rb