On 12/14/07, Lloyd Linklater <lloyd / 2live4.com> wrote:

> There are plenty of tutorials on this.  The first one ask.com gave me is
> http://java.sun.com/docs/books/tutorial/java/concepts/index.html

I feel that I have to caution about trying to import concepts from
other languages directly to Ruby though.

Quoting from the java concepts document section "What is a Class?"

 In the real world, you'll often find many individual objects all of
the same kind. There may be thousands of other bicycles in existence,
all of the same make and model. Each bicycle was built from the same
set of blueprints and therefore contains the same components. In
object-oriented terms, we say that your bicycle is an instance of the
class of objects known as bicycles. A class is the blueprint from
which individual objects are created.

This accurately describes Java classes, but Ruby classes really aren't
blueprints, at least not as I read the Java concept document.

In Java classes stamp out objects like cookie cutters, the cookie
cutter for the gingerbread class has a different shape from that of
the star class.

In Ruby, most classes use exactly the same cookie cutter which gives
the instance a few fields, like a klass pointer, and a pointer to a
hash where instance variables will be accumulated as methods get run
on the object.

To carry out the bicycle analogy a Ruby bicycle assembles itself as
you ride it, and it can magically acquire, say a bell, when you first
need to ring it.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/