[Rejected] SE-0024 Optional Value Setter ??=

The review of SE-0024 "Optional Value Setter ??=“ ran from February 12...18, 2016. The proposal text is here:

  swift-evolution/0024-optional-value-setter.md at master · apple/swift-evolution · GitHub

The proposal is rejected. While the ‘??=‘ operator’s semantics are clear and fit with other compound assignment operators, the use cases are not strong enough to motivate inclusion of this operator. Radek’s lukewarm +0.5 review <http://thread.gmane.org/gmane.comp.lang.swift.evolution/6895&gt; captures the sentiment of the core team fairly well (as was echoed by others): one very common use case in the Ruby’s similar ||= operator is to assign a default value to an optional parameter or a local variable. However, neither case works well in Swift because ??= does not erase the optionality of the variable (and cannot be used to change a parameter now that var has been removed from parameters). Property access and subscripting could still benefit from ??=, but the latter case is likely to be handled better by a Dictionary subscript operator that can substitute a default value (see, e.g., Joe Groff’s suggestion <http://thread.gmane.org/gmane.comp.lang.swift.evolution/6895&gt;\).

  Doug Gregor
  Review Manager