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:



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

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.



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

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.



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

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

#inspectObject

call-seq:

nil.inspect -> "nil"

Always returns the string “nil”.



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

def inspect
  'nil'
end

#nil?Boolean

call-seq:

nil.nil? -> true

Only the object nil responds true to nil?.

Returns:

  • (Boolean)


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

def nil?
  true
end

#to_aObject

call-seq:

nil.to_a -> []

Always returns an empty array.



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

def to_a
  []
end

#to_fObject

call-seq:

nil.to_f -> 0

Always returns zero.



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

def to_f
  0
end

#to_iObject

call-seq:

nil.to_i -> 0

Always returns zero.



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

def to_i
  0
end

#to_procObject

:nodoc:



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

def to_proc # :nodoc:
  nil
end

#to_sObject

call-seq:

nil.to_s -> ''

Always returns the empty string.



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

def to_s
  ''
end

#|(object) ⇒ Object

call-seq:

nil | obj -> true or false

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



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

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