ios - Closure arguments referenced by position inside nested closure in swift -


i have piece of code works fine:

var discoverevents = events.map { event in    userevents.find { $0.eventid == event.eventid } ?? event } 

i wonder if there way reference event position inside find somehow that:

var discoverevents = events.map { userevents.find { $$0.eventid == $0.eventid } ?? $0 } 

to make one-liner?

no, it's not possible. inner $0 shadows outer one, , there no other way refer $0 in outer scope.

as @davidberry mentions, syntax intended short anonymous functions. things confusing otherwise.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -