DEV Community

Discussion on: Level Up Your Ruby Skillz: Writing Compact Code

Collapse
 
enriquemorenotent profile image
Enrique Moreno Tent • Edited

Beware. This 2 lines do not do the same:

x = a.nil? ? b : a
x = a || b

Example:

a = false
b = "foo"

x = a.nil? ? b : a
# x = false

x = a || b
# x = "foo"