From: Doug Glidden <41mortimer@...> Date: 2008-09-09T03:20:42+09:00 Subject: Re: "Pointer" to an object? (i.e. reflect changes to origina Calamitas wrote: [snip] > Or closer to the pointer solution you want: > > p.primary_email = lambda { p.personal_email } > p.personal_email = 'me@gmail.com' > puts p.primary_email.call > > The lambda expression corresponds to the address operator, the .call > corresponds to a pointer dereference. > > Peter Peter, Thanks! I had just (literally within the last ten minutes) thought of the possibility of using an enclosure of some sort to do the trick. I was playing around with using a proc, you used a lambda, I think either one will probably work with some tweaking. This is the "perfect" solution, I think. I'm a little curious how this will react if p.primary_email.call is executed when p is not in scope, e.g. if something like the following occurs, so I'm going to play around: def do_something(person) email = person.primary_email.call # do more stuff... end p = Person.new p.personal_email = 'me@home.com' p.primary_email = lambda {p.personal_email} do_something p Will the lambda be able to handle that situation? Like I said, I'm going to play around with it. Thanks again, Doug -- Posted via http://www.ruby-forum.com/.