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