在类型推断的情况下,编译器会根据上下文推断值的类型。
In type inference, the compiler infers the types of values based on the context.
该决策使语言更加一致、使实现更加易于维护以及提供更多机会以便充分利用将来在类型推断中的改进。
That decision makes the language more consistent, makes the implementation more maintainable, and offers more opportunities to take advantage of future improvements in type inference.
在大多数情况下,方法的返回类型可以被推断,所以“:”和返回类型可以被省略。
In most cases, the return type of the method can be inferred, so the ':' and return type can be omitted.
应用推荐