let sortedNumbers = numbers.sort { $0 > $1 } print(sortedNumbers)
Can anyone explain, what $0 and $1 means in swift?
$0
$1
More Sample
array.forEach { actions.append($0) }
$0 is the first parameter passed into the closure. $1 is the second parameter, etc. That closure you showed is shorthand for:
let sortedNumbers = numbers.sort { (firstObject, secondObject) in return firstObject > secondObject }
1.4m articles
1.4m replys
5 comments
57.0k users