You are correct. I have fundamentally misunderstood the ruby language. It is not the variables I misunderstood though. I have fundamentally misunderstood the operator + and the fact that Fixnums are not modifiable. + is non-destructive and that implies that it is impossible to get rid of x = x + 1 For some reason I though x.+(1) would change the internal state of the object referred to by x which it doesn't of course, it just returns a new object. The only way to eliminate x = x + 1 is to make '+' destructive but this of course cause many problems like the following a = 1 x = a+3 Now 'a' would have the value 4 which is of course bad. Therefore I think I was wrong and single variable assignment is impossible in Ruby. You have to allow variable reassignment in Ruby. Thanks. -----Original Message----- From: Austin Ziegler [mailto:halostatue / gmail.com] Sent: Sunday, January 09, 2005 1:39 PM To: ruby-talk ML Subject: Re: Type inference in ruby On Sun, 9 Jan 2005 05:53:24 +0900, Trevor Andrade <trevor.andrade / utoronto.ca> wrote: [...] > I was just wondering how do they fit together? Are you talking about > multiple assignment as in: > > X = 1 > X = 2 [...] > I think was a bit ambiguous in my email so let me make myself > clear. The term multiple assignment is used in two situation or at > least I use it in two situations. In one situation a variable is > assigned to and then assigned to again. In the other situation, > two variable are assigned to at the same time. Both these > situations are called multiple assignment. I am referring to the > first situation. I believe you are referring to the second. I have > no problem with the second situation. It is the first that I > believe is unnecessary. Unless I am missing something and the two > kinds of multiple assignment are some how related. I don't know your language background. I do not consider this "multiple assignment," even through from a literal perspective it is. Perhaps "variable reassignment" is a better term. It is not a common use of the term in the Ruby community. You have demonstrated a fundamental misunderstanding of Ruby's variables if you at all consider that: x = x + 1 and x.+(1) could or should ever be the same. Not only is #+ not destructive, Fixnums are immutable objects. Variables do not contain values, they contain references to objects. Therefore, you cannot simply modify a variable x containing a Fixnum value; you have to assign a new value into the variable x. Mutable objects (e.g., Strings, Arrays, Hashes, user defined objects) could treat x.+(1) as "the same" as x += 1, but that's because the internal state of the object is being changed. It's still not advisable, because as stated, #+ is usually a non- destructive form. In Ruby, if you want to concatenate strings, you have three choices: "#{a}#{b}" # Creates a new string a + b # Creates a new string a << b # Modifies the string referenced by 'a' Variables, though, aren't objects. They're just slots. -austin -- Austin Ziegler * halostatue / gmail.com * Alternate: austin / halostatue.ca