Class: NilClass

Inherits:
Object show all
Defined in:
lib/source/ruby.rb

Overview

The class of the singleton object nil.

Instance Method Summary collapse

Constructor Details

#initializeNilClass

:nodoc:



4056
4057
4058
# File 'lib/source/ruby.rb', line 4056

def initialize # :nodoc:
  `this.__id__=4`
end

Instance Method Details

#&(object) ⇒ Object

call-seq:

nil & 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.



4065
4066
4067
# File 'lib/source/ruby.rb', line 4065

def &(object)
  false
end

#^(object) ⇒ Object

call-seq:

nil ^ obj -> true or false

Exclusive Or – if obj is nil or false, returns false; otherwise, returns true.



4083
4084
4085
# File 'lib/source/ruby.rb', line 4083

def ^(object)
  `$T(object)`
end

#inspectObject

call-seq:

nil.inspect -> "nil"

Always returns the string “nil”.



4092
4093
4094
# File 'lib/source/ruby.rb', line 4092

def inspect
  'nil'
end

#nil?Boolean

call-seq:

nil.nil? -> true

Only the object nil responds true to nil?.

Returns:

  • (Boolean)


4101
4102
4103
# File 'lib/source/ruby.rb', line 4101

def nil?
  true
end

#to_aObject

call-seq:

nil.to_a -> []

Always returns an empty array.



4110
4111
4112
# File 'lib/source/ruby.rb', line 4110

def to_a
  []
end

#to_fObject

call-seq:

nil.to_f -> 0

Always returns zero.



4119
4120
4121
# File 'lib/source/ruby.rb', line 4119

def to_f
  0
end

#to_iObject

call-seq:

nil.to_i -> 0

Always returns zero.



4128
4129
4130
# File 'lib/source/ruby.rb', line 4128

def to_i
  0
end

#to_procObject

:nodoc:



4132
4133
4134
# File 'lib/source/ruby.rb', line 4132

def to_proc # :nodoc:
  nil
end

#to_sObject

call-seq:

nil.to_s -> ''

Always returns the empty string.



4141
4142
4143
# File 'lib/source/ruby.rb', line 4141

def to_s
  ''
end

#|(object) ⇒ Object

call-seq:

nil | obj -> true or false

Or – returns false if obj is nil or false; true otherwise.



4074
4075
4076
# File 'lib/source/ruby.rb', line 4074

def |(object)
  `$T(object)`
end