The class of the singleton object nil.
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.
static VALUE
false_and(obj, obj2)
VALUE obj, obj2;
{
return Qfalse;
}
Exclusive Or—If obj is nil or false, returns false; otherwise, returns true.
static VALUE
false_xor(obj, obj2)
VALUE obj, obj2;
{
return RTEST(obj2)?Qtrue:Qfalse;
}
Always returns the string “nil”.
static VALUE
nil_inspect(obj)
VALUE obj;
{
return rb_str_new2("nil");
}
call_seq:
nil.nil? => true
Only the object nil responds true to nil?.
static VALUE
rb_true(obj)
VALUE obj;
{
return Qtrue;
}
Always returns an empty array.
nil.to_a #=> []
static VALUE
nil_to_a(obj)
VALUE obj;
{
return rb_ary_new2(0);
}
Always returns zero.
nil.to_f #=> 0.0
static VALUE
nil_to_f(obj)
VALUE obj;
{
return rb_float_new(0.0);
}
Always returns zero.
nil.to_i #=> 0
static VALUE
nil_to_i(obj)
VALUE obj;
{
return INT2FIX(0);
}
Commenting is here to help enhance the documentation. For example, sample code, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.