Replies: 6 comments
-
Expression blocks would be a much more performant and simple way to achieve the same thing. |
Beta Was this translation helpful? Give feedback.
-
@YairHalberstadt More code is needed to do the same thing |
Beta Was this translation helpful? Give feedback.
-
What do you mean? With expression blocks this would be: return n switch {
1 => true,
2 => false,
_ => {
// do something...
true
},
}; |
Beta Was this translation helpful? Give feedback.
-
See #3086 |
Beta Was this translation helpful? Give feedback.
-
You are right, but I need more people's opinions |
Beta Was this translation helpful? Give feedback.
-
Why do we need more syntax here? Both local functions and the original switch statement seem like they'd be natural ways to express the need. Shoehorning a switch expression in when you don't have expressions for the branches seems like an odd choice to me. (Both of these would also avoid the allocations required by use of lambdas.) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Direct calls to lambda functions weren't obvious before, but with the new Switch syntax, the need has become urgent.It is often necessary to execute a block of code after hitting a condition.The existing implementation method is as follows:
propose:
Beta Was this translation helpful? Give feedback.
All reactions