Why does a check for not equal to nil will always return true?

In the code below, I get a yellow warning in Xcode at the return statement saying that it will never be executed.  I don’t understand why.  The return type for locationManager.location is CLLocation?.  It looks like it’s possible for locationManager.location to equal nil.

 

        guard locationManager.location != nil else {
           
            return
           
        }

Powered by WPeMatico

You may also like...

Comments are closed.