【发布时间】:2018-01-21 22:25:03
【问题描述】:
我正在尝试使用运算符 > 作为默认函数参数:
Playground execution failed: error: StackSorting.playground:27:63:
error: expected expression after unary operator
func sort<T>(..., compare: (T, T) -> Bool = >) where T: Comparable { }
^
我解决了,但是...有人知道更短的方法吗?
func sort<T>(..., compare: (T, T) -> Bool = { $0 > $1 }) where T: Comparable { }
【问题讨论】:
标签: swift function closures operators default