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:



4031
4032
4033
# File 'lib/source/ruby.rb', line 4031

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.



4040
4041
4042
# File 'lib/source/ruby.rb', line 4040

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.



4058
4059
4060
# File 'lib/source/ruby.rb', line 4058

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

#inspectObject

call-seq:

nil.inspect -> "nil"

Always returns the string “nil”.



4067
4068
4069
# File 'lib/source/ruby.rb', line 4067

def inspect
  'nil'
end

#nil?Boolean

call-seq:

nil.nil? -> true

Only the object nil responds true to nil?.

Returns:

  • (Boolean)


4076
4077
4078
# File 'lib/source/ruby.rb', line 4076

def nil?
  true
end

#to_aObject

call-seq:

nil.to_a -> []

Always returns an empty array.



4085
4086
4087
# File 'lib/source/ruby.rb', line 4085

def to_a
  []
end

#to_fObject

call-seq:

nil.to_f -> 0

Always returns zero.



4094
4095
4096
# File 'lib/source/ruby.rb', line 4094

def to_f
  0
end

#to_iObject

call-seq:

nil.to_i -> 0

Always returns zero.



4103
4104
4105
# File 'lib/source/ruby.rb', line 4103

def to_i
  0
end

#to_sObject

call-seq:

nil.to_s -> ''

Always returns the empty string.



4112
4113
4114
# File 'lib/source/ruby.rb', line 4112

def to_s
  ''
end

#|(object) ⇒ Object

call-seq:

nil | obj -> true or false

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



4049
4050
4051
# File 'lib/source/ruby.rb', line 4049

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