From: Rodrigo Rosenfeld Rosas Date: 2012-02-15T00:31:15+09:00 Subject: [ruby-core:42630] [ruby-trunk - Feature #6023][Open] Add "a ?= 2" support for meaning "a = a.nil? ? 2 : a" Issue #6023 has been reported by Rodrigo Rosenfeld Rosas. ---------------------------------------- Feature #6023: Add "a ?= 2" support for meaning "a = a.nil? ? 2 : a" https://bugs.ruby-lang.org/issues/6023 Author: Rodrigo Rosenfeld Rosas Status: Open Priority: Normal Assignee: Yukihiro Matsumoto Category: core Target version: 2.0.0 I've just proposed this idea to Groovy and I thought the same semantics would be interesting to have in Ruby too: http://jira.codehaus.org/browse/GROOVY-5306 This is a minor, but important, difference to the "a ||= 2" syntax. This would be a caching/memoization operator, and it would allow code like this: a = nil a ?= false # a is false now a ?= true # a is still false This contrasts with a = nil a ||= false # a is false now a ||= true # a is true now -- http://bugs.ruby-lang.org/