Issue #6561 has been updated by nobu (Nobuyoshi Nakada).


rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
> Would this be valid only for instance variables or any variable?

Only for instance variables, class variables, and global variables.
"undefined local variable" makes no sense.
----------------------------------------
Feature #6561: ?= operator
https://bugs.ruby-lang.org/issues/6561#change-27223

Author: slayer (Vlad Moskovets)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 2.0.0


I have feature proposition to add new opearator ?= its like ||= but assigns only when variable is not defined
So it should be shortcut for

    @var ?= 1

eq

    defined?(@var) ? @var : @var = 1

It should useful for caching nil'able or false'able items



-- 
http://bugs.ruby-lang.org/