From: Patrick Hurley Date: 2006-04-14T03:25:04+09:00 Subject: Re: Question mark in attr_* 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