From: Kelly Felkins Date: 2005-08-09T23:30:53+09:00 Subject: help me understand this ruby idiom: class << self; alias_method :x :y end ------=_Part_11290_2765134.1123597850288 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I'm trying to understand classes and objects. The Pick axe book points out= =20 the "once" method in class Date and how it is defined using the object=20 singleton technique of "class << self". Actually Date uses this in several= =20 places. Up until seeing Date I thought the reason for this idiom was to=20 add/replace methods in classes *when you don't have convenient access to th= e=20 class definition* -- basically, use this when it's not your class you need= =20 to enhance. But the fact that Date uses it several times indicates there is= =20 another reason to use it. Here are some examples from Date: class << self; alias_method :leap?, :gregorian_leap? end class << self; alias_method :new0, :new end I just noticed that every use of class << self in Date contains an=20 alias_method. Please enlighten me. -Your humble pupil Kelly ------=_Part_11290_2765134.1123597850288--