From: ptkwt@... (Phil Tomson) Date: 2004-04-10T02:24:18+09:00 Subject: Re: Would a ':=' operator break anything? In article <4076AA59.4020507@hypermetrics.com>, Hal Fulton wrote: >Yukihiro Matsumoto wrote: > >> |So how about it, would allowing a ':=' operator break anything? >> >> The point is what you want is not assignment in Ruby. It might cause >> confusion that naming ":=" something which is not an assignment. >> Besides that, I may use ":=" for something different in the future, >> although I have no plan now (I had thought to use it once). > >I think I see his point, however. I will make these comments: > >1. I view his := as a kind of limited assignment. > >2. It would fully change the state of the object, but would not > change the class or object id. > exactly. >3. In that sense, it would be like a synonym for #replace on Arrays > and Strings: > str := "hello" # same as str.replace("hello") > arr := [1,2,3] # ... > >4. Of course, this is problematic for Fixnums (etc.), as they are > immediate values and are not mutable. Finxnums (and other immediates) wouldn't have to implement ':=' - actually no class would have to implement it, it would be around in case people want to override it in their own classes. But, as someone mentioned in this thread '<<' could be used for this purpose. So maybe that's the way to go. Phil