From: DracoJK Date: 2007-02-25T06:10:54+09:00 Subject: Just started learning Ruby ------=_Part_69535_29593281.1172351450276 Content-Type: text/plain; charset=ISO-2022-JP; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I've been working through the Humble Ruby Book that I found in a signature of one of ruby talk's list members, and would like a little more explanation as to how pointing to a pointer works. The example used was a string: first_var = "i hold a reference" → i hold a reference second_var = first_var → i hold a reference second_var.chop! # Chops off the last character of the string → i hold a referenc first_var → i hold a referenc This works fine... I understand this... but I tried it with an integer rather than a string, and it doesn't seem to work how I expect it to. first_var = 1 second_var = first_var second_var += 1 puts first_var this outputs 1, but I thought it'd output 2... o_O What's the difference? Why do variables work differently with integers as opposed to strings? Thanks for answering my ever so simple question. :) I come from a java background and never really thought about how things work when you point a variable to another variable. :P ------=_Part_69535_29593281.1172351450276--