On Nov 15, 2007 11:48 AM, Suraj Kurapati <snk / gna.org> wrote: > Marc Heiler wrote: > > (By the way, an accessor_read that can query variables with ? on the end > > would be nice in std ruby too... I am not complaining at all, ruby is so > > flexible, I already use this for my code and i love it, like @file.readable? > > that queries a "special" reader accessor... i think it reads nicer than > > @file.readable but this is just my opinion) > > Do you mean that attr_accessor treats symbols with a question mark > differently by creating a "symbol_without_question=" writer method and a > "symbol_with_question" reader method? For example: > > class Foo > attr_acessor :readable? # defines Foo#readable= and Foo#readable? > end > > f = Foo.new > f.readable? #=> nil > f.readable = 99 > f.readable? #=> 99 > > This would be very useful, because it would make the following > workaround obsolete: > > class Foo > attr_writer :readable # only defines Foo#readable= > > def readable? > @readable > end > end > > Oh wishing star, here is another wish for you! :-) > Thanks for your consideration. I would think that you would want to maintain the ? behavior across the board. In other words, it should return TrueClass or FalseClass objects. Todd