[swift-evolution] Colon vs. equals

Dave Abrahams dabrahams at apple.com
Sat Feb 6 10:11:20 CST 2016


on Sat Feb 06 2016, Haravikk <swift-evolution at swift.org> wrote:

> +1 for changing attributes to using colons, as it would make them read
> more like a function call (albeit one with slightly different rules).
>
> -1 though for changing dictionary literals; personally I think the
> colon syntax is a lot clearer, especially when the literal is being
> assigned, as it means there is only a single, clear assignment.
>
> Regarding assigning new values to a dictionary though, I wonder if we
> might extend the literal syntax to modifying an existing dictionary?
> For example, I might do something like:
>
> 	myDictionary[“foo”: 1, “bar”: 2]	// Add/set new values for foo and bar
>
> As this could be a neater way to replace:
>
> 	myDictionary[“foo”] = 1
> 	myDictionary[“bar”] = 2

This should be spelled

     myDictionary.updateValues([“foo”: 1, “bar”: 2])

or maybe

     myDictionary.update([“foo”: 1, “bar”: 2])
   
-- 
-Dave



More information about the swift-evolution mailing list