Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Spaceship operator

  • <=>

  • Spaceship operator <=> returns -1, 0, or 1

puts 3 <=> 3 # 0
puts 3 <=> 4 # -1
puts 4 <=> 3 # 1

puts "a" <=> "a" # 0
puts "a" <=> "b" # -1
puts "b" <=> "a" # 1