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 problem was to define the return value as an array so that was possible to add element to it.
func anyCommonElements(lhs: T, rhs: U) -> Array {
var result = Array ();
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
result.append(lhsItem);
}
}
}
return result;
}
print(anyCommonElements([1,3,7,9,6,8],rhs:[4,6,8]));