Skip to Content
Learn
The Zen of Ruby
The Ternary Operator

Good! Let’s make our code even more streamlined using the ternary operator.

three = 3 puts three == 3 ? "Of course." : "What?" # ==> puts "Of course."

The example above is just a syntax reminder.

Instructions

1.

Refactor the if statement in the editor to use a ternary operator to puts the correct sentence.

Folder Icon

Take this course for free

Already have an account?