Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Symbol#<=>

<=>(p1)
symbol <=> other_symbol       -> -1, 0, +1, or nil

Compares symbol with other_symbol after calling to_s on each of the symbols. Returns -1, 0, +1, or nil depending on whether symbol is less than, equal to, or greater than other_symbol.

nil is returned if the two values are incomparable.

See String#<=> for more information.

See also .json_create #== .all_symbols #=== also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0