Re:JEP 443: Unnamed Patterns and Variables (Preview)
by cosmotic on Tuesday March 21, 2023 @11:57PM
(#35256637)
I find it exceptionally rare to want not to use a variable that way, it's usually something you want to make harder to ignore, not easier. In the case you really do want to ignore, there are annotations to prevent the warning.
[ Parent
| on HN ]
Re:JEP 443: Unnamed Patterns and Variables (Preview)
by bobbylarrybobby on Wednesday March 22, 2023 @01:02AM
(#35257028)
The underscore is the annotation
Re:JEP 443: Unnamed Patterns and Variables (Preview)
by cosmotic on Wednesday March 22, 2023 @02:01PM
(#35264786)
I understand that; the problem is that it makes it so easy to bypass the safety net the warning is intended to provide. For example, not logging an exception; You'd have to be really intentional to block the warning with an actual annotation, but using an underscore would be so easy you'd just fall into a pattern of always commenting those out. It's better to have a line of code screaming "I'm doing something that looks wrong here but really it's okay" instead of "_".