1
我想使用运营商>
默认函数参数:我可以在Swift中使用运算符作为默认函数参数吗?
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 { }