http://redhanded.hobix.com/inspect/methodsThatSelfDestruct.html
  1.  
  2.  class Trial
  3.     def run_me
  4.        def self.run_me; raise Exception, "NO MORE." end
  5.        puts "Your trial period has ended." 
  6.     end
  7.  end
  8.  
  9.  t = Trial.new
  10.  t.run_me
  11.  #=> Your trial period has ended.
  12.  t.run_me
  13.  #=> (trial):3:in `run_me': NO MORE. (Exception)
好像只是只能调用一次而已,对于一个对象。
Related posts for the current post: