Metaclass, that's new to me.I have to re-read the pick-axe book and
that website, and has a little better understanding now.

Thanks all.

Dorren


On Apr 15, 4:40 am, "eden li" <eden... / gmail.com> wrote:
> Dang, you beat me to it.  I had typed up a similar response.  Here's a
> minor tweak though.
>
> On Apr 15, 4:02 pm, "Harold Hausman" <hhaus... / gmail.com> wrote:
>
> > ... the class <<obj notation, which basically says "build me a new
> > class just for object obj." ...
>
> As far as I can tell, all objects (and thus all classes) already have
> this singleton class.  "class << klass; self; end" is just a way to
> get at it.  why's article defines Object#metaclass as an easy way to
> shorthand this long form syntax.
>
> So, it's pretty clear from the docs that ObjectSpace#each_object takes
> a module/class as a filter and will return only objects which are
> subclasses of said module/class.  If you hand it a metaclass, it does
> simply filters for objects which have metaclasses matching the same
> criteria.
>
> >> class A; end
> => nil
> >> class B < A; end
> => nil
> >> metaclass = class << A; self; end
> => #<Class:A>
> >> B.kind_of?(metaclass)
> => true
> >> B.new.kind_of?(metaclass)
>
> => false
>
> So ObjectSpace#each_object will end up returning only classes
> subclassed from the given "klass" since #kind_of? will hold true for
> only those objects matching that criteria.
>
> I think. ;-)