While Scala has a type inference, it is considered good practice to explicitly define the return type of public functions. Is it possible to get IDEA add the explicit return type from the inferred one?
If you are on a method name then you can hit ALT + ENTER to get the Intention Actions where the first is usually the Add type annotation to function definition
Illustration:
In this case it would add Int
to the return type of the exampleFunction
.
Might I add this also works for val
/var
declarations, essentially whenever there is a type inferred.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With