1

This is the loop in my app:

for var i = column - 1; i >= 0 && burgers[i, row]?.burgerType == burgerType;
        i -= 1, horzLength += 1 {

}

What would be the best way to implement this loop in Swift 2.2.1?

dimo414
  • 47,227
  • 18
  • 148
  • 244

1 Answers1

2

Try this:

var i = column - 1
while i >= 0 && burgers[i, row]?.burgerType == burgerType {
    i -= 1
    horzLength += 1
}

This sort of abuse of the for loop syntax was the exact reason it was deprecated in Swift 2.2. Even if a for syntax was available, this would still be more clear than that abomination

Alexander
  • 59,041
  • 12
  • 98
  • 151