Class: NilClass
Overview
The class of the singleton object nil.
Instance Method Summary collapse
-
#& ⇒ Object
And—Returns
false. -
#^ ⇒ Object
Exclusive Or—If obj is
nilorfalse, returnsfalse; otherwise, returnstrue. -
#inspect ⇒ Object
Always returns the string “nil”.
-
#nil? ⇒ Boolean
call_seq: nil.nil? => true.
-
#to_a ⇒ Array
Always returns an empty array.
-
#to_f ⇒ 0.0
Always returns zero.
-
#to_i ⇒ 0
Always returns zero.
-
#to_s ⇒ Object
Always returns the empty string.
-
#| ⇒ Object
Or—Returns
falseif obj isnilorfalse;trueotherwise.
Instance Method Details
#&(obj) ⇒ false #&(obj) ⇒ false
And—Returns false. obj is always evaluated as it is the argument to a method call—there is no short-circuit evaluation in this case.
993 994 995 |
# File 'object.c', line 993 static VALUE false_and(obj, obj2) VALUE obj, obj2; |
#^(obj) ⇒ Boolean #^(obj) ⇒ Boolean
Exclusive Or—If obj is nil or false, returns false; otherwise, returns true.
1030 1031 1032 |
# File 'object.c', line 1030 static VALUE false_xor(obj, obj2) VALUE obj, obj2; |
#inspect ⇒ Object
Always returns the string “nil”.
863 864 865 |
# File 'object.c', line 863 static VALUE nil_inspect(obj) VALUE obj; |
#nil? ⇒ Boolean
call_seq:
nil.nil? => true
Only the object nil responds true to nil?.
1044 1045 1046 |
# File 'object.c', line 1044 static VALUE rb_true(obj) VALUE obj; |
#to_a ⇒ Array
Always returns an empty array.
nil.to_a #=> []
849 850 851 |
# File 'object.c', line 849 static VALUE nil_to_a(obj) VALUE obj; |
#to_f ⇒ 0.0
Always returns zero.
nil.to_f #=> 0.0
817 818 819 |
# File 'object.c', line 817 static VALUE nil_to_f(obj) VALUE obj; |
#to_i ⇒ 0
Always returns zero.
nil.to_i #=> 0
801 802 803 |
# File 'object.c', line 801 static VALUE nil_to_i(obj) VALUE obj; |
#to_s ⇒ Object
Always returns the empty string.
nil.to_s #=> ""
833 834 835 |
# File 'object.c', line 833 static VALUE nil_to_s(obj) VALUE obj; |
#|(obj) ⇒ Boolean #|(obj) ⇒ Boolean
Or—Returns false if obj is nil or false; true otherwise.
1010 1011 1012 |
# File 'object.c', line 1010 static VALUE false_or(obj, obj2) VALUE obj, obj2; |