I have a feeling I may regret asking this, but when a Swift type conforms to a protocol/has a super type, is there a space before the colon?
The auto-generated swift interfaces use a space. I have discovered that swift-syntax-generated output does not.
"Type: Inheritance" or "Type : Inheritance"
The auto-generated swift interfaces use a space. I have discovered that swift-syntax-generated output does not.
"Type: Inheritance" or "Type : Inheritance"
Comments
"When specifying a type, always associate the colon with the identifier" It continues with rationale "The type specifier is saying something about the identifier so it should be positioned with it."
Just another resource, not necessarily right
https://github.com/github/swift-style-guide
[Key: Value] or [Key : Value]
Struct Baguette : Bread { … }
But look at this:
https://developer.apple.com/documentation/swift/hashable
On my team we always use `A: B`, but we never mind about it when writing it because everything gets correctly formatted with swiftformat before every commit.
Something(
one: 1,
two: 2)
Kill meeeeeeee
Or I just did too much python?
No space before the colon, and that last parenthesis belongs on a new line!
Something(one: 1,
two: 2)
This triggers me every time I see it, especially when other people start using it.
And did you include the closing parentheses like that just to ruin my morning? 😂
Anyway I’m always putting new lines with arguments > 1. Just a matter of readability. One operation per line
Also I just put several files side by side on wider screens:
* protocol
* implementation
* view code
* previews
* etc
Type: Inheritance
https://developer.apple.com/documentation/swift/hashable
https://github.com/swiftlang/swift/blob/cfe6195bbdbcab75ef56ce3dca718296c6641b49/stdlib/public/core/Hashable.swift#L104