Ruby module Comparable interactive
→ Click to get an interactive sample (type in code)
Methods
String
# Uses spaceship <=> operator
<'foo' < 'foo' # false
<='foo' <= 'foo' # true
== (alias eql?)'foo' == 'foo' # true
>'foo' > 'foo' # false
>='foo' >=; 'foo' # true
Numeric
# Uses spaceship <=> operator
<1 < 1 # false
<=1 <= 1 # true
== (alias eql?)1 == 1 # true
>1 > '1 # false
>=1 >=; 1 # true