Swift - Loops
Identify the error in this Swift code:
let values = [1, 2, 3, 4]
for val where val > 2 in values {
print(val)
}let values = [1, 2, 3, 4]
for val where val > 2 in values {
print(val)
}for-in loop syntaxwhere clause must come after in values, not before.wherewhere val > 2 is incorrectly before in values.where clause is placed before in -> Option Awhere goes after in [OK]where after in collection [OK]where before in15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions