Class

The class of the singleton object nil.

Instance Methods

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.

Case Equality – For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in case statements.

Dummy pattern matching – always returns nil.

This method makes it possible to ‘while gets =~ /re/ do`.

Exclusive Or—If obj is nil or false, returns false; otherwise, returns true.

Always returns the string “nil”.

Only the object nil responds true to nil?.

Returns zero as a rational. The optional argument eps is always ignored.

Always returns an empty array.

nil.to_a   #=> []

Returns zero as a complex.

Returns nil represented as a BigDecimal.

require 'bigdecimal'
require 'bigdecimal/util'

nil.to_d   # => 0.0

Always returns zero.

nil.to_f   #=> 0.0

Always returns an empty hash.

nil.to_h   #=> {}

Always returns zero.

nil.to_i   #=> 0

Returns zero as a rational.

Always returns the empty string.

Or—Returns false if obj is nil or false; true otherwise.