ActionsLike0
Feature #5781
openQuery attributes (attribute methods ending in `?` mark)
Description
Pretty sure this has come up before, but I'd like to revisit b/c I don't understand why it isn't allowed.
Sometimes I define "query" attributes, and in those cases I'd like the reader method to end in a ?
mark. Currently I have to do:
# @attribute
def foo?
@foo
end
or, if I don't mind a shadowing bare method,
attr :foo
alias_method :foo?, :foo
So why not just allow:
attr :foo?
Currently this causes an error. But why? It just seems like a waste of potentially cleaner code.
Updated by naruse (Yui NARUSE) over 13 years ago
- Status changed from Open to Assigned
- Assignee set to matz (Yukihiro Matsumoto)
- Target version changed from 1.9.4 to 2.0.0
Updated by ko1 (Koichi Sasada) over 12 years ago
- Target version changed from 2.0.0 to 2.6
Updated by mame (Yusuke Endoh) over 5 years ago
- Related to Feature #12046: Allow attr_reader :foo? to define instance method foo? for accessing @foo added
Updated by mrkn (Kenta Murata) over 5 years ago
- Related to Feature #15991: Allow questionmarks in variable names added
Updated by byroot (Jean Boussier) almost 2 years ago
- Related to Feature #19708: Support `attr_reader :foo?` added
ActionsLike0