Actions
Feature #11939
openSyntax sugar to apply a method replace a variable
Feature #11939:
Syntax sugar to apply a method replace a variable
Status:
Open
Assignee:
-
Target version:
-
Description
There is frequent use case to modify the value of a variable and keep it referred to by the same variable name. When method chaining cannot be done (for example, when the method is conditionally called), the same variable name would have to be repeated:
I would like to propose a syntax sugar for this kind of situation. I have two options in mind.
(1) =.
(2) .=
Notation (2) seems to be in line with syntax sugar like +=, but option (1) has the advantage that the period comes together with the method name.
Updated by nobu (Nobuyoshi Nakada) over 10 years ago
Updated by codetodya (Sumit Mahamuni) over 10 years ago
According to ruby conventions shouldn't that be
var.some_method!(some_args) if some_condition.
Because you are modifying same object. Why do you need new feature?
Updated by sawa (Tsuyoshi Sawada) over 10 years ago
Actions