Hacker News new | ask | show | jobs
by wslh 5169 days ago
If the code block can run in a different thread (like in Grand Central Dispatch) it is very useful to do stuff in the background without blocking the GUI (that executes in a specific thread) and using the current scope variables. A progress bar is a clear example of this.

Doing this without code blocks adds extra code like launching another thread, connecting the scope to the new thread.

1 comments

Sorry, I'm not following. Why couldn't you use a function here instead of a code block to do the exact same thing?