ternary operator

Ruby supports the ability to write if-else conditionals using ?:, the conditional operator (also called the ternary operator). The syntax is a little different, but its compactness makes it very useful.

condition ? return_if_true : return_if_false

For this example, we are going to refactor the code using a ternary operator:
x = 74
if x > 10
result = “big number”
result = “small number”

puts result

Ternary Operator:
x = 74
puts x > 10 ? “It’s a big number!” : “It’s a small number.”

condition: puts x > 10
if statement is true: “It’s a big number!”
else: “It’s a small number.”