Swift 3: Difference between DispatchQueue.main.async {} and DispatcQueue.main.async (execute: {})?

There is a very narrow semantic difference between the two, and I wonder why both options exist. Are they in any other way functional, or maybe it's just a pseudonym of another?

+4
source share
2 answers

What you're talking about is called closure closure syntax. It is syntactic sugar to facilitate the operation of shutters.

There are many other kinds of syntactic sugars that relate to closure, which I describe in my answer here .

, Swift Language guide, , .

+1

. , .

,

myQueue.async(execute: { foo() })

myQueue.async {
  foo()
}

, , . , , DispatchQueue.async, , .

.

, , :

myQueue.async(execute: foo)
+11

Source: https://habr.com/ru/post/1674608/


All Articles