Ruby 3 · Basics
Branch
Use if, unless and the ternary operator. Only nil and false are falsy.
puts n > 0 ? "positive" : "not positive" if n
puts "empty" if list.empty?
Ruby 3 · Basics
Use if, unless and the ternary operator. Only nil and false are falsy.
puts n > 0 ? "positive" : "not positive" if n
puts "empty" if list.empty?
Was this page helpful?