From: "Hal E. Fulton" Date: 2003-06-04T12:39:20+09:00 Subject: Re: case of sub! not working ----- Original Message ----- From: "Ian Macdonald" To: "ruby-talk ML" Sent: Tuesday, June 03, 2003 10:31 PM Subject: Re: case of sub! not working > I understand your reasoning, but why is = any different to sub! ? > If assignment (=) is just a method call with some syntactic sugar thrown > in, then why is it that sub! tries to modify the outside environment, > while = only modifies the singleton copy? It's not really =, it's []=. Real assignment is not a method. The []= *is* a method, one that is named so that it looks like an assignment and fits nicely inside our brains. This is not nitpicking. In some languages, x[y] would give you an lvalue, and then you would call another method =. Here there is only one method call, []=. Look at it this way: Suppose the [] and []= methods were renamed to #get and #set. You would not expect ENV.get(x).sub! to change ENV just because ENV.set(x) does so. Makes sense? Hal