That changes the type of self
, though, from T
to T?
. So how would defaultFoo
behave? For -> Void
functions you could exit early if self
is nil
, but what if the method returns a value?
I would like to have a decent solution for this, as I have a similar problem. Also, there’s a related pitch about requiring an explicit self
when passing methods to escaping closures. So there appears to be some demand for improvements in this part of the language.