本帖最后由 铅笔描绘的思念 于 2012-7-2 11:08 编辑
一般需要goto的话可以用Ruby的throw/catch来做。。。不过。。。RGSSMS没这东西。。。
引用《The Ruby Programming Language》上的例子:
for matrix in data do # Process a deeply nested data structure. catch :missing_data do # Label this statement so we can break out. for row in matrix do for value in row do throw :missing_data unless value # Break out of two loops at once. # Otherwise, do some actual data processing here. end end end # We end up here after the nested loops finish processing each matrix. # We also get here if :missing_data is thrown. end
for matrix in data do # Process a deeply nested data structure.
catch :missing_data do # Label this statement so we can break out.
for row in matrix do
for value in row do
throw :missing_data unless value # Break out of two loops at once.
# Otherwise, do some actual data processing here.
end
end
end
# We end up here after the nested loops finish processing each matrix.
# We also get here if :missing_data is thrown.
end
goto不是Ruby关键字也不是内建方法…… |