# Objects or variables?

**URL:** <https://www.ruby-forum.com/t/objects-or-variables/117834>\
**Category:** Ruby\
**Created:** [October 21, 2007, 4:50am UTC](https://www.ruby-forum.com/t/objects-or-variables/117834 "2007-10-21T04:50:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 21, 2007, 4:50am UTC](https://www.ruby-forum.com/t/objects-or-variables/117834/1 "2007-10-21T04:50:25Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 21, 2007, 6:15am UTC](https://www.ruby-forum.com/t/objects-or-variables/117834/2 "2007-10-21T06:15:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 21, 2007, 6:26am UTC](https://www.ruby-forum.com/t/objects-or-variables/117834/3 "2007-10-21T06:26:57Z")

</div>

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](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(:🙂 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.

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [October 21, 2007, 9:55am UTC](https://www.ruby-forum.com/t/objects-or-variables/117834/4 "2007-10-21T09:55:59Z")

</div>

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
