I'm having an array:
var myArray = ["","dfg","erte","","asd"]
How can I get the index of those elements which doesn't have ""..?
I have this code:
for i in myArray {
let index = myArray.firstIndex(where: {$0 == i})
}
This gives me the index of all elements. But I want the index of those elements which doesn't have ""
index, which you then discard on the next pass through the loop. What is your desired output. You say 'I want the index of those elements which [don't contain] "".' Does that mean you want to create an array containing the indexes of every array element that is not empty?which doesn't have ""You mean the string that aren't empty?