Sha256: 9f75a56b4ccc505a41f239def5f53d56ed63635106a0afc0c7f6323385dc3f0b
Contents?: true
Size: 891 Bytes
Versions: 3
Compression:
Stored size: 891 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 'facets/core/nilclass/to_f' require 'facets/core/nilclass/to_h' require 'facets/core/nilclass/op_fetch' require 'facets/core/nilclass/include' require 'facets/core/nilclass/empty' require 'facets/core/nilclass/size' #require 'facets/core/nilclass/length' # Effectively, the following is what happens: # # 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.49 | lib/facets/core/nil_as_emptiness.rb |
facets-1.8.51 | lib/facets/core/nil_as_emptiness.rb |
facets-1.8.54 | lib/facets/core/nil_as_emptiness.rb |