I\'m trying to complete the exercise on page 46 of Apple\'s new book \"The Swift Programming Language\". It gives the following code:
func anyCommonElements
The cleanest way to solve this in Swift 3 is using the filter function as follows:
func anyCommonElements(_ lhs: T, _ rhs: U) -> [T.Iterator.Element] where T.Iterator.Element: Equatable, T.Iterator.Element == U.Iterator.Element { return lhs.filter { rhs.contains($0) } }