Project

General

Profile

Actions

Feature #19027

closed

.= syntax

Added by jeromedalbert (Jerome Dalbert) over 1 year ago. Updated over 1 year ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:110122]

Description

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.


Related issues 1 (1 open0 closed)

Is duplicate of Ruby master - Feature #6841: Shorthand for Assigning Return Value of Method to SelfAssignedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0