From: "rosenfeld (Rodrigo Rosenfeld Rosas)" Date: 2012-06-13T23:36:08+09:00 Subject: [ruby-core:45630] [ruby-trunk - Feature #6561] ?= operator Issue #6561 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas). exactly, I was just wanting to make sure. My other proposition for ?= would work for local variables as well, although it would always evaluate the expression if the current value is null while this proposition will only evaluate it once. For example, suppose a method like this: def my_method something = nil, something_else = nil my_var = something || something_else my_var ?= begin ... end end Yeah, I know we could do "... || something_else || begin", but #6023 would allow false values to prevent the begin-end block execution. The other approach would be something like: my_var = begin ... end if my_var.nil? Or if my_var.nil? my_var = begin ... end end I'm not strictly defending #6023 because I don't remember needing something like this yet (that's why I couldn't think in a concrete example) as what motivated me to ask for such feature was to be able to cache "false" values in my instance variables, so both #6023 and #6561 would work for me. I'm just stating what are the major differences between them... ---------------------------------------- Feature #6561: ?= operator https://bugs.ruby-lang.org/issues/6561#change-27224 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/