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?

Official Ruby 3 documentation

More basics commands

All basics commands · Ruby 3 cheatsheet

Was this page helpful?