Project

General

Profile

Actions

Feature #6561

closed

?= operator

Added by slayer (Vlad Moskovets) about 10 years ago. Updated over 9 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
[ruby-core:45518]

Description

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


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #6023: Add "a ?= 2" support for meaning "a = a.nil? ? 2 : a"Rejectedmatz (Yukihiro Matsumoto)02/15/2012Actions
Actions

Also available in: Atom PDF