Class: NilClass

Inherits:
Object show all
Defined in:
object.c,
object.c

Overview

The class of the singleton object nil.

Instance Method Summary collapse

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.

Overloads:

  • #&(obj) ⇒ false

    Returns:

    • (false)
  • #&(obj) ⇒ false

    Returns:

    • (false)


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.

Overloads:

  • #^(obj) ⇒ Boolean

    Returns:

    • (Boolean)
  • #^(obj) ⇒ Boolean

    Returns:

    • (Boolean)


1030
1031
1032
# File 'object.c', line 1030

static VALUE
false_xor(obj, obj2)
VALUE obj, obj2;

#inspectObject

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?.

Returns:

  • (Boolean)


1044
1045
1046
# File 'object.c', line 1044

static VALUE
rb_true(obj)
VALUE obj;

#to_aArray

Always returns an empty array.

nil.to_a   #=> []

Returns:



849
850
851
# File 'object.c', line 849

static VALUE
nil_to_a(obj)
VALUE obj;

#to_f0.0

Always returns zero.

nil.to_f   #=> 0.0

Returns:

  • (0.0)


817
818
819
# File 'object.c', line 817

static VALUE
nil_to_f(obj)
VALUE obj;

#to_i0

Always returns zero.

nil.to_i   #=> 0

Returns:

  • (0)


801
802
803
# File 'object.c', line 801

static VALUE
nil_to_i(obj)
VALUE obj;

#to_sObject

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.

Overloads:

  • #|(obj) ⇒ Boolean

    Returns:

    • (Boolean)
  • #|(obj) ⇒ Boolean

    Returns:

    • (Boolean)


1010
1011
1012
# File 'object.c', line 1010

static VALUE
false_or(obj, obj2)
VALUE obj, obj2;