On 12/20/2011 08:03 AM, Yukihiro Matsumoto wrote:
> 
> Issue #5781 has been updated by Yukihiro Matsumoto.
> 
> 
> It's mostly because semantics.  attr :a creates a method corresponding to an instance variable @a.  So naively, attr :a? tries to create an instance variables @a? which is not a valid name for a instance variable.
> 
> I don't want to allow instance variable names ending '?', just because ? is for predicates, not for variables.
> The other option is removing '?' from instance variables.  But as far as I remember no one seriously proposed the idea before, and we haven't got consensus.

How about adding an attr_query method that otherwise works identically
to attr_reader but creates a method with a '?' on the end of the given
name instead?

For example, you could use it like this:

class Foo
  attr_query :bar
  attr_writer :bar
end

foo = Foo.new
foo.bar = true
foo.bar?         # => true
foo.bar = false
foo.bar?         # => false

-Jeremy