Whats the best way to execute code if some optional isn't nil? Clearly, the most obvious way to do it would be to directly check if the value is nil:
if optionalValue != nil {
//Execute code
}
I've also seen the following:
if let _ = optionalValue {
//Execute code
}
The second one seems more in line with swift since it's using optional chaining. Are there any advantages to using one method over the other? Is there a better way to do it? By better I mean "more in line with Swift", whatever that means.
if let optionalValue = optionalValue {.