Skip to Content
The Zen of Ruby
The One-Line Unless

You can do the exact same thing with the unless statement. The order is the same as before: something for Ruby to do, the unless keyword, and then an expression that evaluates to true or false.

Remember, you don’t need an end when you write a one-line if or unless!



Go ahead and type a one-line unless statement in the editor to the right. It can be whatever you like.

Folder Icon

Take this course for free

Already have an account?