Reputation: 55002
Why am I getting this error when the arguments for the function are the same as what's being passed?
class ViewController: NSViewController {
func foo(path: String, arguments: [String], showOutput: Bool) -> Void {
}
@IBAction func a1(_ sender: NSButton) {
let path = "/sbin/ping"
let arguments = ["-c", "5", "google.com"]
self.foo(path, arguments, true){ // I'm getting extra argument in call for true
}
}
Upvotes: 0
Views: 64
Reputation: 4855
func foo(_ path: String,_ arguments: [String],_ showOutput: Bool) -> Void {
/// Prerform task here whic you want to perform while calling this
/// function or task with those Paramaters
}
@IBAction func a1(_ sender: NSButton) {
let path = "/sbin/ping"
let arguments = ["-c", "5", "google.com"]
/// It is just a normal Function that accepts parameteres and
/// Preform requred Task
self.foo(path, arguments, true)
}
Upvotes: 1
Reputation: 318944
The line (with the mysterious extra {
at the end):
self.foo(path, arguments, true){
needs to be:
self.foo(path: path, arguments: arguments, showOutput: true)
The use of self.
is optional.
Upvotes: 0