Glorious Ruby
Posted 2005 Aug 24
I’m sorry, but all of this cool stuff is blowing my mind.
<pre><code> class DwemthysArray < Array alias _inspect inspect def inspect; "#<#{ self.class }#{ _inspect }>"; end def method_missing( meth, *args ) answer = first.send( meth, *args ) if first.life < = 0 shift if empty? puts "[Whoa. You decimated Dwemthy's Array!]" else puts "[Get ready. #{ first.class } has emerged.]" end end answer || 0 end end </code>It takes a minute to grok, then… Whoa.