From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id AA5311F461 for ; Mon, 15 Jul 2019 09:42:39 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7193B120A5B; Mon, 15 Jul 2019 18:42:31 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 0BFD1120877 for ; Mon, 15 Jul 2019 18:42:28 +0900 (JST) Received: by filter0175p3mdw1.sendgrid.net with SMTP id filter0175p3mdw1-30495-5D2C4A83-38 2019-07-15 09:42:27.907802236 +0000 UTC m=+1009308.528634746 Received: from herokuapp.com (unknown [54.172.56.155]) by ismtpd0038p1iad2.sendgrid.net (SG) with ESMTP id do31ifVvQEWUTHuzbYmWOA for ; Mon, 15 Jul 2019 09:42:27.820 +0000 (UTC) Date: Mon, 15 Jul 2019 09:42:27 +0000 (UTC) From: sudo.nice@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 69284 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 5781 X-Redmine-Issue-Author: trans X-Redmine-Issue-Assignee: matz X-Redmine-Sender: sudo X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?m8X2tOGLXBStopIv9ieo7zdjcjz+sjQQ=2F47KDj=2FiIFUuKK35oZWEDypd3JRnUN?= =?us-ascii?Q?lPbXB0pQScgzwnOaZvxSo32oshmIFzQgjYlyLXZ?= =?us-ascii?Q?cHzjc2MWbYB9rNyvQZC=2FB25aPLFS1Z5wmE=2Fh=2FW8?= =?us-ascii?Q?Fi1vXj3OIqyuq+y2VtQcPgJCjuORoobq0a1y1y3?= =?us-ascii?Q?06JWTJ7dz1699BLTugOWnmffcdWCj+TURTw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93785 Subject: [ruby-core:93785] [Ruby master Feature#5781] Query attributes (attribute methods ending in `?` mark) X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #5781 has been updated by sudo (Sudo Nice). How about implementing it similarly to Crystal? attr_accessor? :foo will expand to: def foo=(value) @value = value end def foo? @value end ---------------------------------------- Feature #5781: Query attributes (attribute methods ending in `?` mark) https://bugs.ruby-lang.org/issues/5781#change-79440 * Author: trans (Thomas Sawyer) * Status: Assigned * Priority: Normal * Assignee: matz (Yukihiro Matsumoto) * Target version: ---------------------------------------- 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/