Reputation: 36158
When restricting the type of a generic argument, why is there 2 ways in Swift to do it?
func<T: Type>
func<T>(..) where T: Type
Is there a difference between the two or is this just legacy syntax left behind?
Upvotes: 2
Views: 152
Reputation: 33979
They are identical in function. The first version is there for legacy reasons, it's a holdover from Swift 1. The second version is newer in conception and considered "more proper" by Apple.
Upvotes: 1
Reputation: 63369
There is no difference, and I'm not aware of a convention.
Personally, prefer the first option, unless it makes the rest of the line have to line-break, in which case I use the second option instead.
Upvotes: 3