All Questions
Tagged with switch-statement enums
409
questions
1
vote
1
answer
34
views
_Generic Statement For An Enumerator (Enum)?
I frequently have to deal with the functionality of enums in C. However, there doesn't seem to be an easy & equally efficient way of supplying a different result based off of a predefined enum ...
1
vote
1
answer
30
views
Generating a unique value using 2 different enums to act as cases in a switch statement
I am trying to make a collision system with multiple collider types (ie AABB and circle). A unique method for checking collision needs to be run for each type of collider. In order to determine the ...
0
votes
2
answers
761
views
Angular 17 @switch with Enum Constants
I want to use the new angular @switch statement to show different elements based on a Enum.
enum State {
Loading,
Loaded,
Error
}
@Component({
...
})
export class MyComponent {
state: State = ...
1
vote
2
answers
108
views
Why switch case is working weird on enum types in c++?
I tried to debug below cpp code in gdb having an enum variable and accessing it in switch case statement. Here as you can see vtype is assigned var4 so it should go in case var4, but it is going in ...
0
votes
0
answers
112
views
Can clang-format align "using enum" C++20 statement inside switch expression?
Assuming the following snippet:
switch (val) {
case SomeEnum::SomeValue:
doSomething(val);
case SomeEnum::SomeOtherValue:
doSomethingElse(val);
default:
break;
}
in C++20 we can instead ...
-1
votes
1
answer
57
views
Swift switch case let syntax - access function defined on nested enum [closed]
I need to access a function defined on a nested enum. My setup is the following:
var currentlyShowingStepIndex:Int?
var allSetupSteps:[SetupStep] = []
enum SetupStep {
case districtSetupStep(...
1
vote
3
answers
108
views
Using a Switch-Case with an enum that has string values, in Java?
In my application, I receive a response that has hard-coded values it can be.
I have created an enum with those responses as so:
enum ResponseCode {
APPROVED("AP"),
REJECTED("RJ&...
0
votes
3
answers
95
views
Compare string with toString() representation of enum value using switch in Java
I have a long list of enumerations that are being referenced and selected via if-statements in my code, however, I want to use switch statements as I have a huge number of such statements in multiple ...
0
votes
1
answer
229
views
Control reaches end of non void function after switch case statement
I have a piece of code where I do a switch case statement for all the values of an enum class. All the branches have a return statement, but the gcc (at leat 10.5 and trunk) still thinks that the ...
0
votes
1
answer
42
views
How to compare Object.keys for keys taken from an enum?
I have an enum
enum Blockchain {
Ethereum,
Sepolia,
}
and an object:
const coinName = {
[Ethereum]: 'ETH',
[Sepolia]: 'SETH',
}
Now, I would like to call a function based on ...
-1
votes
1
answer
91
views
Java switch-case with Enum variables "Constant expression required" error
I have this enum:
public enum Pebble {
RAGE(NamedTextColor.DARK_RED, "Rage Wave", "Channel Rage"),
FLEET(NamedTextColor.AQUA, "Dash", "Speed Surge"),
...
-1
votes
2
answers
629
views
Covering unreachable default clause in switch case in java
I have below code snippet, and I'm not sure how to cover the default clause with a unit test.
public Block solve(String str) {
try {
final BlockType blockType = BlockType....
1
vote
1
answer
180
views
Searching for PowerShell syntax for multiple enum values in the case block of a switch statement?
An example of what I want to do:
enum Fruit {
Apple
Banana
Orange
}
$myFruit = [Fruit]::$UsrString
switch ($myFruit) {
Apple, Orange {
Write-...
4
votes
1
answer
162
views
Why is this cast redundant in C#? [duplicate]
This is OrderStatus enum:
public enum OrderStatus
{
[Display(Name = "Gözləmədə")]
Pending,
[Display(Name = "Qəbul olundu")]
Accepted,
[...
1
vote
2
answers
466
views
Why is Java's switch enum so painfully slow on the first run compared to its 'if' equivalent?
Why is Java's switch enum so painfully slow on the first run compared to its 'if' equivalent?
I'm aware that the JVM needs to "warm-up" before performance can be reliably measured. Therefore ...