Hi --

On Thu, 24 Aug 2006, ara.t.howard / noaa.gov wrote:

> On Thu, 24 Aug 2006, James Edward Gray II wrote:
>
>> On Aug 23, 2006, at 3:13 PM, dblack / wobblini.net wrote:
>> 
>>> # Sigh -- Matz, *please* can we have this? :-)
>>> def singleton_class
>>>   class << self; self; end
>>> end
>
> much better, imho, and used all over my own code is
>
>  def singleton_class &b
>    sc = class << self; self; end
>    b ? sc.module_eval &b : sc
>  end
>
> obj = Object.new
>
> obj.singleton_class{ def foo() 42 end }

I'd rather not see module_eval wrapped/hidden in singleton_class.  I
see singleton_class as a kind of twin method with class.  In part I'm
hoping for this because I think it will make it vastly easier for
people to understand the basic premise that an object has a [birth]
class and a singleton class, from both of which it draws its
behaviors.  I don't see an advantage to adding a special twist to
singleton_class.  If it gives you a class object, you can always call
module_eval on that, as with any class object.


David

-- 
http://www.rubypowerandlight.com => Ruby/Rails training & consultancy
   ----> SEE SPECIAL DEAL FOR RUBY/RAILS USERS GROUPS! <-----
http://dablog.rubypal.com        => D[avid ]A[. ]B[lack's][ Web]log
http://www.manning.com/black     => book, Ruby for Rails
http://www.rubycentral.org       => Ruby Central, Inc.