I am trying to make a function to see if all my textfields are filled in, I pass it an array, Let’s say var array = ["1", "2", "3"]
And I want to check the if statement if array[0].isEmpty || array[1].isEmpty || array[2].isEmpty
But it has to be variable, so I thought about using a for loop and using the operator as a variable, that doesn’t work, at least not how I am doing it, does anyone have an idea for this?
var op = false
for field in array {
op += field.isEmpty
op += ||
}
if op {
}
Kind regards
Daan
2
Answers
You could do the check as
As suggested by @MartinR in the comments you can use
contains
instead which makes it a bit neater and with the same performanceTry