You could use joined() to flatten the nested array in a single one, and apply the contains search on the joined array:
let elements2 = [[10], [20, 30], [40, 50]]
if elements2.joined().contains(50) {
print("Contains 50!")
}
Note that you needn't include the type annotation for elements2 above, as the type is inferred (to [[Int]]).
Another alternative would be to use contains to check each inner array for the 50 element, and proceed if any of the inner arrays contains the value:
if elements2.map({ $0.contains(50) }).contains(true) {
print("Contains 50!")
}
Or, using reduce to fold the inner arrays to a boolean, checking the possible inclusion of 50 in each inner array (quite similar approach to the one above)
if elements2.reduce(false, { $0 || $1.contains(50) }) {
print("Contains 50!")
}