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

Hak*_*ari 2 ruby exception-handling

foo, bar = 1, 0/0 rescue 0, 0 # this won't work
foo.should eql 0
bar.should eql 0
Run Code Online (Sandbox Code Playgroud)

我怎么去做这个通行证?

sep*_*p2k 5

foo, bar = ([1, 0/0] rescue [0, 0])
Run Code Online (Sandbox Code Playgroud)