Closure sent as method parameter


(Andrei Mihai Mereuta) #1

Hey what do you think?


(Jordan Rose) #2

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