[swift-evolution] Optional dictionary subscripts

John Holdsworth mac at johnholdsworth.com
Tue Dec 22 05:37:54 CST 2015


This isn’t the most compelling of ideas but a couple of times I’ve found myself writing:

if let value = key != nil ? dict[key] : nil {…

and was wondering if the syntax could be:

if let value = dict[key?] {…

The key for dictionaries could be made optional in stdlib but this is probably best implemented in the compiler for safety.

Cheers


More information about the swift-evolution mailing list