Reputation: 20080
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?
Upvotes: 7
Views: 2666
Reputation: 4966
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.
Upvotes: 15