2015-05-28 32 views

回答

0

是的,我們能做到在begin - rescue循環未來。我們可以按照以下方式做到這一點 -

for i in 1..10 
    begin 
    do_something_that_might_raise_exceptions(i) 
    raise ExpectedError1 => error1 
    next # do_something_* again, with the next i 
    raise ExpectedError2 => error2 
    next # do_something_* again, with the next i 
    end 
end 
+0

我們可以在開始時多付一次救援嗎? – marriedjane875

+0

是的,我們可以在開始循環中進行多次救援。 –