You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check cases where the min or max functions are used unnecessarily, particularly when a simple comparison between two values could be clearer and more efficient.
Why is this bad?
Using min or max for two values introduces unnecessary function calls and makes the code less readable. A simple if-else comparison is both clearer and more efficient for such cases.
Example
x.max(100).min(0);
Use instead:
if x > 100 {
return 100;
} else if x < 0 {
return 0;
} else {
return x;
}
The text was updated successfully, but these errors were encountered:
What it does
Check cases where the min or max functions are used unnecessarily, particularly when a simple comparison between two values could be clearer and more efficient.
Why is this bad?
Using min or max for two values introduces unnecessary function calls and makes the code less readable. A simple if-else comparison is both clearer and more efficient for such cases.
Example
Use instead:
The text was updated successfully, but these errors were encountered: