5 ms·
Types for method and constructor parameters are always explicitly specified. Type inference generally used for local variables and method return types. This str
by thebluesky 14y ago
Types for method and constructor parameters are always explicitly specified. Type inference generally used for local variables and method return types. This strikes a good balance between having no type info (e.g. python) and having type info for everything (java). The convention in Scala is to specify the return type of a method if the return type is complex.
In practice the type which is inferred is pretty obvious:
val x = 800
vs.
val x: Int = 800