Hi -- On Sun, 5 Oct 2008, Ruby Student wrote: > On Sun, Oct 5, 2008 at 6:37 AM, Lex Williams <etaern / yahoo.com> wrote: > >> when writing : >> >> string2 = string1 >> >> both your variables reference the same address , so , modifications to >> any of them will cause modification to the other . >> >> If you write : >> >> string2 = string1.clone >> >> then you will modify just string2 , when writing sub! >> -- >> Posted via http://www.ruby-forum.com/. >> >> > But, why then, the following is not true??? > n1 = 100 > n2 = n2 > > To this point the are the same, including the object_id. > But when I assign: > n2 = 200 > The n1 does not change and the object_id of n2 change. When you assign to a variable, you break any previous binding the variable had. a = "string" b = a #1 b = 100 #2 At #1, the identifiers 'a' and 'b' refer to the same object. At #2, however, 'b' has been bound to another object. Nothing you do to the string in a will affect the object in b (100). David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!