如何在没有开始和结束块的情况下在 Ruby 中使用救援 [英] How does one use rescue in Ruby without the begin and end block
本文介绍了如何在没有开始和结束块的情况下在 Ruby 中使用救援的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道开始救援结束的标准技巧
I know of the standard technique of having a begin rescue end
如何单独使用救援块.
它是如何工作的,它如何知道哪些代码正在被监控?
How does it work and how does it know which code is being monitored?
推荐答案
方法def"可以作为开始"语句:
A method "def" can serve as a "begin" statement:
def foo
...
rescue
...
end
这篇关于如何在没有开始和结束块的情况下在 Ruby 中使用救援的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文