November 2024
Intermediate to advanced
300 pages
7h 12m
English
Temporary variables (“temps”) have a number of uses. They can cache the value of an expensive computation or collect things that change throughout the body of a method. A temp can also clarify the intent of code—a valid choice even if it’s used only once.
In matches, the answer local variable provides none of those three benefits. You can inline such a pointless variable by replacing any occurrences of it with the answerMatching(criterion) expression. In IntelliJ IDEA, inline a variable by following these steps:
Any references to the variable are replaced with the right-hand side of the assignment. The ...
Read now
Unlock full access