【发布时间】:2014-01-22 17:45:29
【问题描述】:
我有以下代码
# colours a random cell with a correct colour
def colour_random!
while true do
col, row = rand(columns), rand(rows)
cell = self[row,col]
if cell.empty? then
cell.should_be_filled? ? cell.colour!(1) : cell.colour!(0)
break
end
end
end
做什么并不重要,尽管它应该很明显。关键是 Rubocop 给了我一个警告
切勿将 'do' 与多行 'while 一起使用
为什么我不应该这样做?那我该怎么做呢?
【问题讨论】:
标签: ruby while-loop rubocop