From: Robert Klemme Date: 2006-02-02T06:51:37+09:00 Subject: Re: Class vs. Object James Herdman wrote: > I'm new to Ruby, and relatively new to OOP (1.5 years of Java -- but > nothing too serious. I didn't really bother to try and understand it > deeply). > > I'm trying to grok the difference between a class and an object. My > understanding of an object is that it is a thing, and that a class is > the description of said thing's behavior. Is this correct? Yes. > Lastly, programmatically, what is the difference between a Ruby object > and class? A Ruby class is an object at the same time. It's an instance of class Class. If this sounds wired it's the usual feeling in the beginning. Once you get more used to it you'll see how powerful this is. >> String.class.ancestors => [Class, Module, Object, Kernel] >> "".class.ancestors => [String, Enumerable, Comparable, Object, Kernel] >> String.kind_of? Class => true >> String.kind_of? Object => true >> "".kind_of? Class => false >> "".kind_of? Object => true >> "".kind_of? String => true Kind regards robert