7.11.2006
4:26 PM
Expiring a method. And let’s keep meta out of this.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)The run_me overwrites itself. But notice it uses def self. This overwrites the method in the object, not in the class. So you can create more Trial objects which haven’t self-destructed yet.
Now that is neat. When I get home later tonight (I'm on lunch break now, I've got about 5 minutes), I'm going to see how I can apply this technique to Io, if at all.
Ciao.