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
I was able to get it to work by making the return value an Array of T.GeneratorType.Element.
func anyCommonElements (lhs: T, rhs: U) -> Array {
var toReturn = Array()
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
toReturn.append(lhsItem)
}
}
}
return toReturn
}
anyCommonElements([1, 2, 3], [3])