I'm using Xcode 8.2.1. If I look at the documentation for Array I find this declaration for the max
method:
public func max(by areInIncreasingOrder: (Element, Element) throws -> Bool) rethrows -> Element?
The argument label is by
and the argument name is areInIncreasingOrder
. Since the label is specified explicitly I thought it has to be included in a call to the function but the following code works if I omit the label (i.e by
).
Am I misunderstanding how argument labels are used when calling a method? Or, is my example code calling a different version of the max
method?
Example code:
let names = ["Talyor", "Paul", "Adele"]
let longest = names.max { $1.characters.count > $0.characters.count }
print(longest!) // "Taylor