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
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
#=> undefind method "to_str" for #<runtimeerror:foo>
文章轉自莊周夢蝶 ,原文釋出時間 2008-10-03