查看: 1369|回复: 1

[已经解决] ruby有没有go_to?

[复制链接]
梦石
0
星屑
50
在线时间
58 小时
注册时间
2011-8-21
回帖
25
发表于 2012-7-2 10:48:50 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
就是可以跳转到哪几行的方法
梦石
0
星屑
2306
在线时间
1010 小时
注册时间
2012-4-30
回帖
1455

开拓者

发表于 2012-7-2 11:07:59 | 显示全部楼层
本帖最后由 铅笔描绘的思念 于 2012-7-2 11:08 编辑

一般需要goto的话可以用Ruby的throw/catch来做。。。不过。。。RGSSMS没这东西。。。
引用《The Ruby Programming Language》上的例子:
[pre lang="ruby" line="1"]
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  [/pre]
goto不是Ruby关键字也不是内建方法……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部