How to mark ignore return values in Java code?… here is a solution to the problem.
How to mark ignore return values in Java code?
There is a C convention to flag functions being called just for side effects, and in this particular call we are not interested in return values:
(void) getSomethingAndDoAction(...);
Is there any equivalent in Java?
Solution
Error Prone project has one @CheckReturnValue
annotation can be used for this purpose.
This makes ignoring return values compile-time errors unless you suppress the error using annotations: @SuppressWarnings("CheckReturnValue"
).