[swift-evolution] [Discussion] Design guideline rule for `:`

Charlie Monroe charlie at charliemonroe.net
Wed Jun 22 06:49:23 CDT 2016


I was always wondering what's the preferred way. Xcode generates the second version for classes and even the stdlib is using the first version (space before and after colon) for protocol conformation/inheritance, though I prefer the second one.

IMHO the guideline doesn't necessarily be uniform for all cases - e.g. in case of vars, the preference can be different than with the inheritence.

> On Jun 22, 2016, at 1:40 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Should there be a design guideline rule for colons : in Swift?
> 
> I see people doing things like this:
> 
> protocol A : B {}
> 
> // VS.
> 
> protocol A: B {}
> func foo<T : A>() -> T { … }
> 
> // VS.
> 
> func foo<T: A>() -> T { … }
> var value : Type
> 
> // VS.
> 
> var value: Type
> [key1 : value1, key2 : value2]
> 
> // VS.
> 
> [key1: value1, key2: value2]
> I prefer the second style, where there is no whitespace between lhs and the : symbol and there is also a whitespace after :. Example: something: somethingElse
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160622/6cd0b8c4/attachment.html>


More information about the swift-evolution mailing list