kelin
(Vladimir Kelin)
1
It seems like it's impossible without intermediate functions. (Sorry, didn't found a similar question)
Lantua
2
Recursive closure would create reference cycle, esp. when all reference to it is strong in current version of Swift. That's why it's not allowed (AFAIK).
kelin
(Vladimir Kelin)
3
Really. And there is no way to pass weak reference to the closure itself into the closure?
Lantua
4
I don't think so. You can't even have weak var for closure.
Lantua
5
In any case I'd suggest you create a local function for what you want to do.
Often time you'll find that closure's power of capturing variable doesn't bode well with recursive logic to begin with.
3 Likes