【发布时间】:2011-06-24 11:15:52
【问题描述】:
我正在使用mm 方法。在 ruby 1.9.2 中,它的行为很奇怪,而不是预期的结果 1.9.2=>10 我得到了
ELSE **
1.9.2=>8
知道发生了什么吗?
class A
def mm(data)
begin
send_len = data
return send_len
rescue Exception
STDOUT.write("Rescue *#{$!}*\n")
else
STDOUT.write("ELSE *#{$!}*\n")
end
end
end # class A
a = A.new
print "#{RUBY_VERSION}=>#{a.mm(10)}\n"
在 1.8.7 中,我得到了预期的结果:
1.8.7=>10
【问题讨论】:
-
已阅读 Dave Thomas 等人的“Programming Ruby 1.9”一书第 355 页上的“异常”,但没有用...
-
@Evgeny Shadchnev 为什么在标题中提到 1.8.6?我将其更改为 1.8.7。
-
@sawa 抱歉,打错字了。你是对的。
标签: ruby exception ruby-1.9 ruby-1.9.2 ruby-1.8