Jeremy Henty wrote:
> On 2006-12-05, Edwin Fine <efine145-nospam01 / usa.net> wrote:
> 
>> How about a Ruby Quiz for the funniest way to shoot yourself in the
>> foot with Ruby?
> 
> Years ago I posted this, to overwhelming silence:
> 
Thanks for responding - this time there's a bit of noise at least!
Let me try one.

class Myself
  def shoot_in_foot
    foot = Foot.new(:side => :right)
    hand = Hand.new(:side => :right)
    gun = Gun.new(:make => "Freedom Arms",
                  :type => :revolver, :action => :single,
                  :caliber => ".454 Casull Magnum")
    hand.grasp(gun)
    hand.grasped_object do |gun|
      gun.load
      gun.cock
      gun.aim(:at => foot)
      gun.pull_trigger # => "Bang!"
    end
    hand.drop_object # => Thump!
    self.scream
    foot.inspect
  end
  def scream
    "Arghhhhhhhhhhhhhhhhhhhhhhhh!!!!"
  end
end

myself = Myself.new # I feel like a new man!
myself.shoot_in_foot

=> "Bang!"
=> "Thump!"
=> "Arghhhhhhhhhhhhhhhhhhhhhhhh!!!!"
=> NameError: undefined local variable or method `foot' for 
#<Myself:0xb7573ee4>
# Oops, blew it clean off!

-- 
Posted via http://www.ruby-forum.com/.