通常在rescue
子句中,异常被捕获并且代码在开始块之后恢复。使用 retry
语句,可以在捕获异常后从开始恢复rescue
块代码。
语法:
begin
code....
rescue
# capture exceptions
retry # program will run from the begin block
end
64、Ruby中 retry
语句如何使用?
通常在rescue
子句中,异常被捕获并且代码在开始块之后恢复。使用 retry
语句,可以在捕获异常后从开始恢复rescue
块代码。
语法:
begin
code....
rescue
# capture exceptions
retry # program will run from the begin block
end