What you see printed as Infinity
and NaN
are just the string representations for two special instances of the Float
class, not keywords or literals. They are returned by floating point division by 0 or by referencing the constants Float::INFINITY
and Float::NAN
.
Float::INFINITY.class
# => Float
Float::INFINITY.to_s
# => "Infinity"
Float::NAN.class
# => Float
Float::NAN.to_s
# => "NaN"