From: Justin Collins Date: 2006-04-14T03:33:00+09:00 Subject: Re: Question mark in attr_* --------------070004080909020902030104 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Patrick Hurley wrote: > On 4/13/06, Mike Fletcher wrote: > >> Justin Collins wrote: >> [...] >> >>> This could be pretty handy...but I don't understand why you have the >>> double negation? >>> >>>> define_method("#{sym}?") { !!instance_variable_get("@#{sym}") } >>>> >> Maybe so the first ! coerces to a true or false, and the second flips it >> back to the proper value (so you can set it with whatever value, but the >> accessor will always return true or false). >> >> >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> >> > > Exactly -- you could remove it all together, but this way the method > always returns true/false regardless of the value of the property. > > pth > Okay, makes sense. Thanks, Justin --------------070004080909020902030104--