[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:01815] Re: Objects nested sometimes.

From: Dave Thomas <Dave@...>
Date: 2000-03-14 12:48:34 UTC
List: ruby-talk #1815
Hugh Sasse Staff Elec Eng <hgs@dmu.ac.uk> writes:

> I asked someone about how to do this neatly on an OO way, and they 
> said, "have the ports contain references to the voltages".  However,
> I cannot see any reference or pointer types in ruby.  Is there a
> neat way of doing this in ruby?

In Ruby, variables _are_ references to objects, so you could implement 
your port with (say) an array of voltages, and the node as an array of 
ports.

Say you have

   v1 = "Fred"
   v2 = v2

Then in terms of memory and references, what you've done is assigned a 
reference to the String "Fred" to v2, and then copied that reference
to v2.


    v1 ---------
                \    __String____
                 -->|            |
                 -->|  Fred      |
                /   |____________|
    v2 ---------

(sorry, I missed the ASCII art class at school)

Regards


Dave

In This Thread