June 25, 2018, 12:37 p.m.
IT | Rants

Swift Bugs

I spent 5 minutes trying to bash my head figuring out why the following code did not push out the token:

if token != nil && token!.isEmpty {
  pushOutToken(token)
}

only to realize that the funky Swift unwrapping operator ! applied to token looks - at a quick glance - like a not operator transposed in position, hence the reason for me missing it. I am used to Java, C, C++, C# and tens of other languages that uses the ! as a not operator. Correct code should be:

if token != nil && !token!.isEmpty {
  pushOutToken(token)
}

Go figure...