Closure sent as method parameter

Hey what do you think?

We've got an idiom that will do what you want already!

public static let mainSession = URLSession(configuration: {
  var configuration = URLSessionConfiguration.default
  return configuration
}()) // note the extra () indicating that the closure is immediately called
10 Likes