From: gwtmp01@... Date: 2005-07-12T13:11:38+09:00 Subject: Re: class_attr_accessor On Jul 11, 2005, at 11:20 PM, David A. Black wrote: > I sometimes wonder whether all the "class << self" examples obscure > the > fact that this is a general-purpose thing. In case that's the case, > here's an example: > > str = "I am a string" > class << str > def x > puts "method illustrating singleton class" > end > end It always seems clearer to me when written as: str = "I am a string" def str.x puts "method illustrating singleton class" end I understand that the method is really defined in the anonymous singleton class associated with str but the 'def object.method' syntax is more self-explanatory (to me) than the 'class <