[swift-evolution] Proposal: Remove the space before the colon in compiler-generated [Key : Value] dictionary types

Charles Srstka cocoadev at charlessoft.com
Thu Jan 14 16:44:37 CST 2016

I’ve tried it both ways, but I’ve found that the I prefer the space on both sides of the colon for dictionary literals. The symmetry makes it easier to read, and to distinguish the elements from each other. All IMO, of course.


> On Jan 14, 2016, at 3:38 PM, David Sweeris via swift-evolution <swift-evolution at swift.org> wrote:
> I use " : " (space on both sides) for everything except type annotations & generic constraints. Didn't realize I was doing it wrong.
>> On Jan 14, 2016, at 11:35, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
>> Dictionary type shorthand syntax is meant to look like a dictionary literal, and dictionary literals are almost universally written with no space before the colon. It makes sense to me for dictionary types to be written the same way, e.g. `[Key: Value]`. Not only does this look more like a dictionary literal, but I'd argue it also reduces confusion. Every other case that I can think of where you find space-colon-space syntax used is when declaring the bounds of a generic type parameter, or declaring the superclass/protocols of a type declaration (which is pretty similar to declaring the bounds). But in the syntax `[Key : Value]`, Value is not a bound on Key.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

More information about the swift-evolution mailing list