Reputation: 41
When coding in Swift, if I call a method of a struct and the method has only one parameter do I need to state the label of the parameter or only the value?
Upvotes: 1
Views: 748
Reputation: 107131
That depends on your implementation.
If your implementation is something like this:
func myMethod(myParam: String) -> String
{
return "Midhun is \(myParam)"
}
You can call the method like:
yourObj.myMethod("good");
If your implementation have explicit argument name, like:
func myMethod(character myParam: String) -> String
{
return "Midhun is \(myParam)"
}
You need to call it using:
yourObj.myMethod(character: "good");
Upvotes: 2