From: Mark Hubbart Date: 2004-06-23T05:29:44+09:00 Subject: Re: A question about Class and Object On Jun 22, 2004, at 9:28 AM, Sam Sungshik Kong wrote: > aaClass = aClass.new #->Works! foo = Class.new do define_method :initialize do |color| @color = color end end #=># red_foo = foo.new(:red) #=>#<#:0x5ce10 @color=:red> You can create classes and add methods to them by just passing blocks to method calls :) Note that you need to be very careful if you do things this way... both the class and the initialize method were defined using blocks, so they use the current binding. So if you had a local variable named 'color' set... > So Class is actually a class maker. > It's instances are classes. > That means that to make a class, I don't have to define a class. > If I just create an instance of Class, it's a class. > > When I think of Class and Object, the "chicken and egg" problem comes > to my > mind. > Object is an instance of Class and Class inherits from Object. > Which one is first? (Which one should exist first?) yes, I agree... the mind boggles :) cheers, Mark