Open Luro02 opened 1 month ago
It makes the code smarter. Note: This is difficult to notice, wouldn't make sense to subtract for this.
No response
complexity
return switch (string) { case "A" -> MyEnum.A, case "B" -> MyEnum.B, case "C" -> MyEnum.C, case "D" -> MyEnum.D, default -> throw new IllegalArgumentException("invalid input string: " + string); };
Could be written as:
for (var value : MyEnum.values()) { if (string.equals(value.toString())) { return value; } } throw new IllegalArgumentException("invalid input string: " + string);
What it does
It makes the code smarter. Note: This is difficult to notice, wouldn't make sense to subtract for this.
Lint Name
No response
Category
complexity
Example
Could be written as: