@summercoolness: "Just want to confirm Ruby's
  a = b
is the same as PHP5's
  $obj1 = $obj2
in other words, the reference is copied.
While
  $obj1 =& $obj2
or
  $obj1 = &$obj2
in both PHP4 and PHP5 isn't the same as Ruby's   a = b
$obj1 and $obj2 just become synonyms...
and after
$obj1 = new Foo("foo1");
$obj2 =& $obj1
$obj2 = new Foo("bar1");
$obj1 and $obj2 have the same content, as they are just synonyms. (not a
clone, not same reference, but just synonyms).  The "foo1" object is
garbage-collected since no one is referencing it.
this is giving me an initial headache... until maybe after i get used to
it.
Posted via <url>"
    @jansvitok: "<quote>
in ruby:
a = Hash.new # a is a reference to Hash object #1
b = a # both a and b point to the same object
a[1] = 'a' # and b[1] is 'a' as well
but
b = Hash.new # now a points to Hash obj #1 and b to #2
b[1] = 'c' # a[1] is still 'a'
i.e. assignment may destroy the link."
    @iw1junk: "<quote>
The first pargraph may or may not be correct.  I do not know, since I 
know nothing about PHP and little about UNIX.
The second cannot be correct.  Variables in Ruby do not have a type, 
they reference objects.  Moreover,  when b is a variable
   a = b
always means the same thing, and that does not depend on the type
of object referenced by b!
The line (a = b) means that the variables, a and b, reference the same
object UNTIL either reference is changed.  Changing the reference to
one will mean they no longer refer to the same object.  Changing some
reference within the object will not change what either variable
refers to, BUT the common object referred to is modified.  This is
true for all types of objects in Ruby.
In Jonas' example, the difference is that the object created by
   a = A.new
is capable of having a name and the line
   a.setName('Jonas')
creates a reference to a string within that object.  Since a and b
still refer to the same object either one can change the reference,
@name, i.e. they can change the name and then both a and b will know
about that change.  Once either a or b refers to a different object
the link or common reference for a and b is broken!
The Fixnum class is different from the A class in that the only way to
change the value of a Fixnum object is to create a new object and
hence a new reference; while in A changing the name does not create a
new object, it modifies the object already created.
I think the basic problem is that in many languages variables refer to
a particular place in memory with a given structure.  Ruby on the
other hand makes a variable refer to an object not a place in memory.
Anyone coming from the first type of language to Ruby has a big
adjustment to make in handling the language.  (I know I did when I
first jennifergarcia@example.org.)  Often it doesn't seem to matter, but that
just makes the adjustment harder because the difference is less
visible.
Ian Whitlock
Posted via <url>"
    @dolgun: "<quote>
That is from C++.  Those are "reference" semantics.  It causes two names 
to refer to the same spot in memory where a value is stored.  Either 
name can be used to change the value at that spot in memory, and since 
both names always refer to that same spot in memory, either name can be 
used to retrieve the new value there.
The difference is this next step:
You used assignment in that step.  In other words, you reassigned to 
num1.  In your previous example you never used assignment to reassign 
anything to a; instead you changed the object that a referred to.
Posted via <url>"
{'source': 'USENET', 'other_information': '{"reply_count": 3, "forum_name": "comp.lang.ruby.20141025.mbox"}', 'file': 'data/output/usenet-comp.lang.parquet'}