From: "David A. Black" Date: 2005-01-26T11:10:19+09:00 Subject: Re: attr Hi -- On Wed, 26 Jan 2005, Trans wrote: >> Oh, and I think that the :x! feature is quite useless. This is >> an extremely rare special case and I think it's more obvious >> if written out. Or did you find lots of use cases for it? > > No. The only thing that comes to mind is in combination with a casting. > Somthing like: > > | attr :a! => :upcase > > which creates > > | def a!(x) > | @a.replace(x.upcase) > | end But think of that from the point of view of someone using the class, and writing code in a different file. What you'd see is just this (using 'text' as the accessor): require 'some_file' obj = A.new obj.text = "Hi there." obj.text! puts obj.text # "HI THERE." which is awfully obscure. In essence, there's a verb missing; it's like doing: some_string! instead of some_string.upcase! Also, !-methods don't have any special correspondence to the 'replace' operation. All the ! means is that the operation is dangerous (I think that's the adjective Matz has used) -- which often means it changes the receiver, but doesn't have to, and it could be a change that isn't a replace operation. David -- David A. Black dblack@wobblini.net