Reputation: 407
func taskWithMethod(URLString: String, parameters: [String: AnyObject]?, queryParameters: [String: AnyObject]? = nil){}
What is the difference between parameters
and queryParameters
in this function? Looks like queryParameters
is being defined to nil, but I can still pass the queryParameters
value to this function.
Upvotes: 0
Views: 65
Reputation: 63271
That's a Default Parameter Value (see section "Default Parameter Values"). If no value is passed in, it defaults to nil
.
For example, this function can be called like so:
taskWithMethod(URLString: someString, parameters: dict1, queryParameters: dict2)
but it can also be called like so:
taskWithMethod(URLString: someString, parameters: dict1)
in which case queryParameters
is set to its default value, nil
.
Upvotes: 2