例如,以下代码中是否存在do会影响程序的行为吗?
while true do puts "Hi" break end while true puts "Hi" break end
解决方法
根据
The Ruby Programming Language书第5.2.1节:
The
do
keyword in awhile
oruntil
loop is like thethen
keyword in an
if
statement: it may be omitted altogether as long as a newline (or
semicolon) appears between the loop condition and the loop body.
所以,不,它不会改变行为,它只是可选语法.