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.
987 988 989 |
# File 'object.c', line 987 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.
1024 1025 1026 |
# File 'object.c', line 1024 static VALUE false_xor(obj, obj2) VALUE obj, obj2; |
#inspect ⇒ Object
Always returns the string “nil”.
835 836 837 |
# File 'object.c', line 835 static VALUE nil_inspect(obj) VALUE obj; |
#nil? ⇒ Boolean
call_seq:
nil.nil? => true
Only the object nil responds true to nil?.
1038 1039 1040 |
# File 'object.c', line 1038 static VALUE rb_true(obj) VALUE obj; |
#to_a ⇒ Array
Always returns an empty array.
nil.to_a #=> []
821 822 823 |
# File 'object.c', line 821 static VALUE nil_to_a(obj) VALUE obj; |
#to_f ⇒ 0.0
Always returns zero.
nil.to_f #=> 0.0
789 790 791 |
# File 'object.c', line 789 static VALUE nil_to_f(obj) VALUE obj; |
#to_i ⇒ 0
Always returns zero.
nil.to_i #=> 0
773 774 775 |
# File 'object.c', line 773 static VALUE nil_to_i(obj) VALUE obj; |
#to_s ⇒ Object
Always returns the empty string.
nil.to_s #=> ""
805 806 807 |
# File 'object.c', line 805 static VALUE nil_to_s(obj) VALUE obj; |
#|(obj) ⇒ Boolean #|(obj) ⇒ Boolean
Or—Returns false if obj is nil or false; true otherwise.
1004 1005 1006 |
# File 'object.c', line 1004 static VALUE false_or(obj, obj2) VALUE obj, obj2; |