[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: ruby wish-list
From: Suraj Kurapati <snk () gna ! org>
Date: 2007-11-15 17:48:07
Message-ID: 5e6a15b789404d00bf99b5711b26c4fe () ruby-forum ! com
[Download RAW message or body]
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.
--
Posted via http://www.ruby-forum.com/.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic