Group Group Group Group Group Group Group Group Group

Difference between "as? NSError" and "as NSError?"

In some chapters of the book there’s lines like this:

if let error = error as NSError?

whereas in Swift I usually see optional binding like this:

if let something = something as? Type

Can someone explain the difference and why we’re using “as Type?” instead of “as? Type”, I don’t get it.

Thank you!

1 Like