From: Austin Ziegler Date: 2004-06-04T05:37:13+09:00 Subject: Re: variable -- set value > -----Original Message----- > From: Angel Martin [mailto:angel@tyrex.mine.nu] > > El mar, 01-06-2004 a las 17:40, Mark Hubbart escribi�: >> String#replace replaces the contents of the string with the >> argument passed. But everything in ruby is done by reference, so >> there is no clean way of doing what you are talking about that >> works for every type. This is one of those things that really >> bugged me at first, but I eventually liked; Not being able to do >> tricks like that doesn't seem to hamper my code any, and leaves >> it much easier to understand. >> >> I would recommend leaving the pointers to C and Perl :) > IMHO, why not a generic replace for every class: > 'Object#self=' class?? foo = "bar" f_foo = File.open(foo) foo.self = f_foo # Boom? foo = 5 foo2 = foo * 2 foo.self = foo2 # Boom! The evilruby project has added #become capability -- of sorts, I think. The real trick is that Ruby variables aren't objects or memory blocks, but labels for object references. Subtle, but important. Once that is clear, a lot of false expectations will be cleared as well. -austin -- austin ziegler * austin.ziegler@evault.com