You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "nmatt (via GitHub)" <gi...@apache.org> on 2026/01/25 16:45:32 UTC
[I] Assign Return Value To New Variable for switch expressions [netbeans]
nmatt opened a new issue, #9162:
URL: https://github.com/apache/netbeans/issues/9162
### Description
The hint Assign Return Value To New Variable is available for most expressions, but not for switch expressions.
### Use case/motivation
Example:
```java
enum FooBar { FOO, BAR };
FooBar fooBar = FooBar.FOO;
switch (fooBar) { case FOO -> 10; case BAR -> 20; };
```
The hint should be available on the *switch* line and result in:
```java
int [name] = switch (fooBar) { case FOO -> 10; case BAR -> 20; };
```
For comparison, it is available on:
```java
fooBar == FooBar.FOO ? 10 : fooBar == FooBar.BAR ? 20 : -1;
```
The usefulness should hopefully be obvious.
### Related issues
_No response_
### Are you willing to submit a pull request?
No
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists