An explicit return type is mandatory for expression bodied functions, but if the function is generic the compiler still attempts to infer the return type from the type of the body.
test[T](t: T) -> List[T] => [t, t, t]
test should have return type List[T] as explicitly specified, but instead it has return type T[], inferred from the type of its expression body.
An explicit return type is mandatory for expression bodied functions, but if the function is generic the compiler still attempts to infer the return type from the type of the body.
test
should have return typeList[T]
as explicitly specified, but instead it has return typeT[]
, inferred from the type of its expression body.