Why is the Enumerable module considered the heart of Ruby, and what is the role of the spaceship (<=>) operator?

Last updated 27 June 2026

  • Enumerable is central because it gives nearly every collection one consistent, intent-revealing iteration vocabulary built only on each.

  • The spaceship operator <=> returns -1, 0, or 1 (or nil if not comparable). sort, min, max use it for ordering.

  • Define <=> and include Comparable to get <, >, ==, and between? for free.

  • https://www.turing.com/interview-questions/ruby
  • https://www.youtube.com/watch?v=lkunzd5uDrw
  • https://blog.jacobvosmaer.nl/0004-ruby-scheduler-interaction/
  • https://wohotech.in/coding/top-java-interview-questions
  • https://jetthoughts.com/blog/ruby-3-4-yjit-performance-guide/
  • https://speed.ruby-lang.org/
  • https://flexiple.com/python/interview-questions
All Ruby interview questions