"do" expressions
"do"
The do keyword can be used to reduce indentation.
The below examples are equivalent:
do can go in front of if, for, for*, trusted, unless, until, with, or while.
All lines after the line with the do are treated as if they were an indented block.
This can chain to reduce many levels of indentation:
"do if" and "do unless"
Unlike a normal if, the condition in a do if or do unless can take an indented block.
A do if or do unless can still have an else branch.
If so, it goes to the right of the condition.
(This means the condition must fit on one line.)
The else branch can be an indented block.
Use do if and do unless when you want to emphasize a main path where all the ifs succeed.