From: "Dan0042 (Daniel DeLorme)" Date: 2022-09-28T14:36:27+00:00 Subject: [ruby-core:110127] [Ruby master Feature#19027] .= syntax Issue #19027 has been updated by Dan0042 (Daniel DeLorme). I don't think that works. `var += expr` is a shortcut for `var = var.+(expr)`. But `var .= method` translates to `var = var.method`; the right-hand side is not an expression, so it's a very different kind of construct. But I'm a fan of the "fluent interface" style, so I wouldn't mind `records = .where.not(id: excluded_ids)` :-) (I would also love fluent-style `foo && .bar` `foo and .bar` `foo{ .bar }` but #16120 has been rejected once so I don't think there's much hope.) ---------------------------------------- Feature #19027: .= syntax https://bugs.ruby-lang.org/issues/19027#change-99385 * 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/ Unsubscribe: