I've been wondering if unwrapping weak self within the escaping closure's scope brings some benefits other than aesthetical ones? Consider those two examples:
When we unwrap self:
func test() {
Test.closureFunction { [weak self] parameter in
guard let self = self else { return }
self.someFunction(parameter)
}
}
When we don't unwrap self:
func test() {
Test.closureFunction { [weak self] parameter in
self?.someFunction(parameter)
}
}
Could there be a scenario when not unwrapped self (1st example) may become nil as a result of some other asynchronous operation, thus the execution of the scope may differ from when we unwrap self (2nd example)? I believe it's a possible scenario, but I may be wrong.
I think that we may still want to execute an operation from within the escaping closure's scope while self is already nil. After this escaping closure finishes its scope the unwrapped self is released.
Thank you