Posted on 2008-10-03 13:26
dennis 閱讀(550)
評論(0) 編輯 收藏 所屬分類:
動態語言
1、
異常的相等性,如果兩個異常的class、message和backtrace一樣,那么認為這兩個異常是相等的,可以通過==判斷。
def method
raise 'foobar'
end
errors = []
2.times do
Thread.new do
begin
method
rescue => e
errors << e
end
end.join
end
puts errors[-2] == errors[-1] #=> true (1.9) false(1.8)
2、
SystemStackError現在繼承Exception類,而非原來的StandardError:
1.8
SystemStackError < StandardError # => true
1.9
SystemStackError < StandardError # => nil
SystemStackError < Exception #=> true
3、
移除了Exception#to_str方法:
begin
raise "foo"
rescue
$!.to_str
end
#=> undefind method "to_str" for #<RuntimeError:foo>