0

Is there any functional difference between defining a generic constraint like this:

func compare<T: Comparable>(l: T, r: T) -> Bool {
   return l == r
}

or with a where clause like this:

func compare<T>(l: T, r: T) -> Bool where T: Comparable {
   return l == r
}

I see examples of both in the Swift docs and both compile properly. So which should I use & when?

0 Answers0