而其中一个参数现在变成了内联闭包(相比于backwards版本的代码)。 根据上下文推断类型(Inferring Type From Context) 因为排序闭包函数是作为sort函数的参数进行传入的,Swift可以推断其参数和返回值的类型。
基于24个网页-相关网页
在类型推断的情况下,编译器会根据上下文推断值的类型。
In type inference, the compiler infers the types of values based on the context.
对于向上转换运算符,如果编译器无法根据上下文推断出特定的目标类型,则将报告错误。
As for the upcast operator, if the compiler cannot infer a specific target type from the context, it reports an error.
在使用向上转换运算符时,编译器会尝试根据上下文来推断出要转换为的类型。
When you use the upcast operator, the compiler attempts to infer the type you are converting to from the context.
应用推荐