Nathan Morse wrote:
> What about when I don't use String#+ ?

Look at it this way. You're not "passing by reference." You're
passing references by value. :)

Learn to distinguish between variables and objects. The former
are merely "labels" if you will.

    a = b = c = "hello"     # three variables, one object

Then remember that assignment always "wipes out" the old reference.
Assignment doesn't change the old object at all.

    a = b = "hi"   # a and b both refer to "hi"
    a = "bye"      # but now a refers to "bye"

So assigning a variable is different from changing an object.
Look at this:

    a = b = "hi"
    b[0] = "f"
    p a           # "fi"

We're changing the *object* referred to by b (which is the same
one referred to by a). We're not making b refer to a different
object.

Or check this out. Both result in the value "foobar" -- but there
is a difference.

    a = "foo"
    b = "foo"
    p a.object_id    # -542440758
    p b.object_id    # -542444578

    a << "bar"
    b += "bar"
    p a.object_id    # -542440758
    p b.object_id    # -542466128  (a new object!)

Does this help any?


Hal