From: "Earlopain (Earlopain _) via ruby-core" Date: 2026-07-13T18:42:19+00:00 Subject: [ruby-core:126074] [Ruby Feature#5781] Query attributes (attribute methods ending in `?` mark) Issue #5781 has been updated by Earlopain (Earlopain _). Status changed from Assigned to Closed Sadly https://bugs.ruby-lang.org/issues/21555#note-10 > I still ask you to define def valid? = @valid manually. It is not much worse than attr_reader :valid?. ---------------------------------------- Feature #5781: Query attributes (attribute methods ending in `?` mark) https://bugs.ruby-lang.org/issues/5781#change-118074 * Author: trans (Thomas Sawyer) * Status: Closed * Assignee: matz (Yukihiro Matsumoto) ---------------------------------------- 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. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/