From: Phillip Gawlowski Date: 2011-08-10T04:02:47+09:00 Subject: Re: Problem in typical code On Tue, Aug 9, 2011 at 8:38 PM, amir e. wrote: > EXCUSE ME !!!!!!!!!! > THIS IS THE CODE : No need to use caps. :) > class Fixnum >  def seconds >    self >  end >  def minutes >    self * 60 >  end >  def hours >    self * 60 * 60 >  end >  def days >    self * 60 * 60 * 24 >  end > end Explanation of the code: If you type this into irb, and write something like "2.days", the Fixnum 2 (Fixnums are a bit of a special case in Ruby, since they don't usually get created, but just *are*) gets multiplied by seconds, minutes, then hours. This happens because "self" is a keyword in Ruby, which means "I want to do this to myself". A made up example: class Car def turn_key self.motor = "on" end def motor=(state) # A manually created 'setter method' @motor = state # "@motor" is an 'instance variable', meaning it is valid only within a single Car object. end end -- Phillip Gawlowski phgaw.posterous.com | twitter.com/phgaw | gplus.to/phgaw A method of solution is perfect if we can forsee from the start, and even prove, that following that method we shall attain our aim.               -- Leibniz