如何在Ruby中挽救多项任务?

时间:2010-11-08 20:18:17

标签: ruby exception-handling

foo, bar = 1, 0/0 rescue 0, 0 # this won't work
foo.should eql 0
bar.should eql 0

我该怎样做这个通行证?

1 个答案:

答案 0 :(得分:5)

foo, bar = ([1, 0/0] rescue [0, 0])