I'm trying to write a function that I can call with trailing closure syntax like so:
func hello( message: String, closure: (( msg: String ) -> Void)?) {
println( "called hello with: \(message)" );
closure?( msg: message );
}
I would expect to be able to call this function with a closure:
hello( "abc" ) { msg in
let a = "def";
println("Called callback with: \(msg) and I've got: \(a)");
};
And also without the closure, since it's optional:
hello( "abc" )
The latter doesn't work. It says I can't call hello with an argument list of (String).
I'm using XCode 6.3.2 and I tested this code within a playground.