From: Austin Ziegler Date: 2005-05-06T22:08:54+09:00 Subject: Re: object reference handle (like perl's reference to scalar) On 5/6/05, dave.burt@gmail.com wrote: >> Can someone give me an example of a time you need an extra level >> of indirection? > A reference can sort of replace itself with another object. > > An Integer is immutable, but a reference to an integer can be > changed to any other object. > > a = [1, 2, 3].map {|i| i.ref } > a.each {|i| > i[] = 5.1 if i == 2 > end > > Something analogous to the above might be better (clearer?) than > #map or #each_with_index in some cases. I disagree. After all, you've had to use map to replace the integers with Ref-to-integer in the first place. I still haven't seen any reason that this would be necessary -- or even useful -- in Ruby. (IMO, John Carter's nil-as-message eater would be more useful. And I think it's clear how useful I think *that* is.) -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca