News for hackers. Stuff that matters.
Re:Fun with Swift by DrJokepu on Monday January 04, 2016 @08:32PM (#10840322)
Cocoa and Cocoa Touch were designed with imperative programming in mind though, so this is what the creators of Swift had to work with. I think the main use case for mutable captured values is mutable self, in particular the following, extremely common pattern:

    dispatch_async(my_background_queue) {
        do_some_io()
        let result = do_expensive_computation()
        dispatch_async(dispatch_get_main_queue()) {
            self.value = result
            update_ui()
        }
    }

There are no comments on this comment yet.