Brian Candler wrote: > On Tue, May 01, 2007 at 07:14:43PM +0900, Nic Daniau wrote: (...) >> why does it say "self.quality = 50" in the example and not "@quality = >> 50"? > > I guess it's just standard accessor syntax, where it's considered > cleaner to > call a setter method (which might implement additional logic) rather > than > twiddle directly with instance variables in an object, which are usually > considered 'private' > > Brian. Brian's explanation is correct. I learned this technique from the 1st edition of Hal Fulton's "The Ruby Way." I think I remember seeing it in the 2nd edition, too, although I don't have my copy with me to check. I'm using this technique to support the dozen or so optional arguments that Image#write can accept. Overall it works well, although since the block is executed in the context of an RMagick object, all that object's instance variables are exposed to the caller. RMagick mitigates this problem by running the block in the context of an Image::Info object, which doesn't have any private data or methods, just attribute accessors. -- Posted via http://www.ruby-forum.com/.