Objects or variables?

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.

http://poignantguide.net/ruby/chapter-4.html

ratchet.attach() is a static method?

ratchet is an object or a static class?

starmonkey is an object, yes? Of what class?

thank you,

Thufir

On Oct 20, 2007, at 10:50 PM, Thufir wrote:

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

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.

http://poignantguide.net/ruby/chapter-4.html

ratchet.attach() is a static method?

He doesn’t say, and I don’t think that is the point of the example. The
example shows you how to call a method. Whether it’s a static/class
method or a regular method is irrelevant. However, on the previous page
there is a clue:


Class methods

Like the methods described above (also called instance methods), class
methods are usually attached after variables and constants. Rather than
a dot, a double colon is used.

Door::new( :oak )

Since 1) ratchet does not start with a capital letter, and 2) there is
no scope resolution operator(::slight_smile: after ratchet, you can draw your own
conclusions.

ratchet is an object or a static class?

Once again, that’s irrelevant to the example. But since ratchet doesn’t
start with a capital letter…

starmonkey is an object, yes?

Yes, but everything is an object in ruby, so that doesn’t say much about
starmonkey.

Of what class?

The Starfish class.

On Sun, 21 Oct 2007 13:26:56 +0900, 7stud – wrote:

Like the methods described above (also called instance methods), class
methods are usually attached after variables and constants. Rather than
a dot, a double colon is used.

Door::new( :oak )

Ah, yes thanks. Also, that Ruby doesn’t have static typing I find
confusing – but will continue on!

Thanks again,

Thufir