ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:110122] [Ruby master Feature#19027] .= syntax
@ 2022-09-28 13:03 jeromedalbert (Jerome Dalbert)
  2022-09-28 13:30 ` [ruby-core:110123] " hmdne (hmdne -)
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeromedalbert (Jerome Dalbert) @ 2022-09-28 13:03 UTC (permalink / raw)
  To: ruby-core

Issue #19027 has been reported by jeromedalbert (Jerome Dalbert).

----------------------------------------
Feature #19027: .= syntax
https://bugs.ruby-lang.org/issues/19027

* Author: jeromedalbert (Jerome Dalbert)
* Status: Open
* 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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-28 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [ruby-core:110125] " mame (Yusuke Endoh)
2022-09-28 14:32 ` [ruby-core:110126] " austin (Austin Ziegler)
2022-09-28 14:36 ` [ruby-core:110127] " Dan0042 (Daniel DeLorme)

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).