Skip to content
instance method

Numeric#<=>

(::Numeric other) -> ::Integer
self <=> other → zero or nil

Compares self and other.

Returns:

  • Zero, if self is the same as other.

  • nil, otherwise.

Class Numeric includes module Comparable, each of whose methods uses Numeric#<=> for comparison.

No subclass in the Ruby Core or Standard Library uses this implementation.

See also #-@ #abs #+@ #abs2 also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0