From: Morton Goldberg Date: 2007-10-21T13:15:02+09:00 Subject: Re: objects or variables? On Oct 20, 2007, at 10:50 PM, Thufir wrote: > I'm going by "Why's (poignant) Guide to Ruby": > > starmonkey = ratchet.attach( captive_monkey, captive_star ) > > The ratchet gets an attach message. What needs to be attached? The > method arguments: the captive_monkey and the captive_star. We are > given back a starmonkey, which we have decided to hang on to. > > > > ratchet.attach() is a static method? > > ratchet is an object or a static class? Ruby is a dynamic language -- nothing is static in the sense of Java or C++. Further, every expression evaluates to an object, so ratchet.attach(captive_monkey, captive_star) returns an object (of some kind --- _why doesn't tell us what kind and it doesn't matter much -- class is not the big deal in Ruby that it is in languages with static typing of variables). ratchet is an object of a class that has an attach method which knows how, given a monkey and a star. to produce something _why calls a starmonkey. > starmonkey is an object, yes? Of what class? The variable starmonkey is bound to the object returned by the expression on the right-hand side of the assignment -- it can be used, for some execution extent, to refer to that object. Regards, Morton