Reputation: 2328
I don't fully understand the following code. I can identify there is a trailing closure. I don't know why
but it's valid.
self.getImages(request) { images in // this line I don't understand
if let images = images {
// do something
} else {
// do something
}
}
Upvotes: 1
Views: 125
Reputation: 4066
You can read it like this:
self.getImages(request, completion:{ images in // this line I don't understand
if let images = images {
// do something
} else {
// do something
}
})
images
is the parameter of your closure.
This syntax is called trailing closure, here documentation.
Upvotes: 1