From: Rick DeNatale Date: 2009-06-28T22:12:38+09:00 Subject: Re: Attr Methods and object setters On Sun, Jun 28, 2009 at 9:01 AM, Fabian Streitel wrote: > If you like that method better -- noones keeping you from using it. And I > admit, > for DSLs it is pretty nice. I'd use it there. > >> Nothing = Object.new >> def name(value = Nothing) >>    @name = value unless value == Nothing >>    @name >> end > > Or Daniel's method. I'd probably use Daniel's method. I've found Object.new to create a null value(not to be confused with nil) or sentinel value, quite useful at times, in both Ruby and Smalltalk. Basically this gives you an object which is useful (only) because it has a unique identity and is guaranteed not to appear by chance. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale