Project

General

Profile

Feature #6561

?= operator

Added by slayer (Vlad Moskovets) about 8 years ago. Updated almost 8 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

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

Also available in: Atom PDF