Operators and Expressions

== != < > <= >= <=> (spaceship returns -1, 0, 1) == (value), eql? (value + type), equal? (identity), === (case equality)

&& || ! (high precedence), and or not (low precedence, for control flow) cond ? a: b .. (inclusive), ... (exclusive)

=~ (regex), in, => (pattern matching) *args, **opts, &block

Operators are methods: 1 + 2 is 1.+(2). You can define +, ==, [], <=>, <<, !, unary -@/+@, etc. in your classes (Module 21).

5 <=> 3              # 1
1 == 1.0             # true
1.eql?(1.0)          # false
a = "x"; a.equal?(a) # true
Integer === 5        # true  (used by case/when)
(1..10) === 5        # true
/ab/ === "cab"       # true
x = nil
x ||= 10             # 10
y = 5
y &&= y + 1          # 6
user = get_user or raise "not found"   # `or` for control flow