Class: NilClass
Overview
Adds a couple of methods in NilClass and modifies the behaviour == slightly so that it returns true for nil-equivalent objects if they return true for nil?
In default, it seems the judgement is based on other.__id__. Note that the method eql? (and of course equal?) unchange.
Here is the summary of the changes:
-
#nowhere? is added, which returns
false. -
#class_raw is added, which returns NilClass
-
(nil == RangeExtd::Nowhere::NOWHERE) returns
true
To activate these features, explicitly do either of the following
require "range_extd/nil_class"
require "range_extd/load_all"
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
returns true if other returns true with
nil?. -
#class_raw ⇒ Class
Identical to
nil.class. -
#double_equals? ⇒ Object
No overwriting.
-
#nowhere? ⇒ Boolean
returns true.
Instance Method Details
#==(other) ⇒ Boolean
returns true if other returns true with nil?.
37 38 39 |
# File 'lib/range_extd/nil_class.rb', line 37 def ==(other) other.nil? end |
#class_raw ⇒ Class
Identical to nil.class
28 29 30 |
# File 'lib/range_extd/nil_class.rb', line 28 def class_raw self.class end |
#double_equals? ⇒ Object
No overwriting.
32 |
# File 'lib/range_extd/nil_class.rb', line 32 alias_method :double_equals?, :== |
#nowhere? ⇒ Boolean
returns true
21 22 23 |
# File 'lib/range_extd/nil_class.rb', line 21 def nowhere? false end |