我知道这个问题已经在其他地方提到过,但是我对if elseruby 中多行(块?)语句的正确语法有点困惑。
举个例子:
if condition then
do something
do somethingelse
do yetanotherthing
done
else
do acompletelyunrelatedthing
done
我知道then如果使用多行,则该语句是必需的,但是done之前是else必需的吗?这似乎会脱离if...else上下文。当我包含这个时,done我得到:
syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
当我不包括它时,我得到:
syntax error, unexpected keyword_else, expecting keyword_end