http://redhanded.hobix.com/inspect/methodsThatSelfDestruct.html
- class Trial
- def run_me
- def self.run_me; raise Exception, "NO MORE." end
- puts "Your trial period has ended."
- end
- end
- t = Trial.new
- t.run_me
- #=> Your trial period has ended.
- t.run_me
- #=> (trial):3:in `run_me': NO MORE. (Exception)
好像只是只能调用一次而已,对于一个对象。固定链接: http://liubin.nanshapo.com/2006/07/14/%e8%87%aa%e5%b7%b1%e9%94%80%e6%af%81%e8%87%aa%e5%b7%b1%e7%9a%84%e6%96%b9%e6%b3%95%e3%80%82/ | 其实我是一个程序员
最新评论