Ruby: Continue a loop after catching an exception Ruby: Continue a loop after catching an exception ruby ruby

Ruby: Continue a loop after catching an exception


In Ruby, continue is spelt next.


for i in 1..5    begin        do_something_that_might_raise_exceptions(i)    rescue        next    # do_something_* again, with the next i    endend


to print the exception:

rescue        puts $!, $@        next    # do_something_* again, with the next iend