From: "mame (Yusuke Endoh)" <noreply@ruby-lang.org>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:110125] [Ruby master Feature#19027] .= syntax
Date: Wed, 28 Sep 2022 14:30:43 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-99383.20220928143043.13834@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-19027.20220928130316.13834@ruby-lang.org
Issue #19027 has been updated by mame (Yusuke Endoh).
Status changed from Open to Rejected
If I remember correctly, this has been proposed several times. I found one ticket #6841, so I'll close this as a duplicate.
----------------------------------------
Feature #19027: .= syntax
https://bugs.ruby-lang.org/issues/19027#change-99383
* Author: jeromedalbert (Jerome Dalbert)
* Status: Rejected
* Priority: Normal
----------------------------------------
I wish I could do this in Ruby:
```
records .= where.not(id: excluded_ids) if some_condition
```
instead of:
```
records = records.where.not(id: excluded_ids) if some_condition
```
We already have `+=`, `-=`, `||=`, etc, so why not have a `.=` syntax?
I rarely need this since most of the time self replacement methods like `gsub!` are available. Over my many years of Ruby programming I wished I could use a `.=` syntax maybe a handful of times, so this would be a rarely useful feature, but I find it to be quite elegant in the rare cases it could be needed.
Maybe this is just me being weird but I thought I would share.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2022-09-28 14:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 13:03 [ruby-core:110122] [Ruby master Feature#19027] .= syntax jeromedalbert (Jerome Dalbert)
2022-09-28 13:30 ` [ruby-core:110123] " hmdne (hmdne -)
2022-09-28 14:30 ` mame (Yusuke Endoh) [this message]
2022-09-28 14:32 ` [ruby-core:110126] " austin (Austin Ziegler)
2022-09-28 14:36 ` [ruby-core:110127] " Dan0042 (Daniel DeLorme)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-99383.20220928143043.13834@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).