Questions tagged [switch-statement]
In computer programming, a switch, case, select or inspect statement is a type of selection control mechanism used to invoke specific blocks of code based on variable contents.
switch-statement
11,811
questions
1
vote
1
answer
44
views
Switch executes default even with break in every case
So i'm trying to break out of the switch and while statements using the break in every case, yet even using the break statement my program keeps executing the default after the specific case code is ...
0
votes
0
answers
35
views
How can I switch to pop up facebook sign up page in Selenium?
I am not able to switch to pop up facebook sign up page using selenium.Tried switch to method but still not working.
FB Signup page
Tried below code
public void createNewAccount() {
driver....
0
votes
1
answer
87
views
Can you break out of a switch case from within a loop?
I have a list of objects that I don't want to contain duplicates. Since the objects are expensive to create, I don't want to use a set, as that requires an object to be created first, before ...
2
votes
2
answers
127
views
Runtime cast of void pointer
I'm writing a C program that applies a different type of quantization to an array depending on an environmental variable.
The problem is that, I need to use the same function void foo(void* ptr, ...
1
vote
1
answer
148
views
Using bash case statement in gitlab ci/cd to set variables
I'm trying to create a pipeline and set some variables from gitlab based of the git branch, in my case staging, master and everything else branch:
---
stages:
- deploy
- pre
- pro
....
1
vote
1
answer
123
views
how to use switch case statement to filter result set based on condition in c#
i am working on a task where i am sending a status as parameter in request and want to filter based on that status and one other column from database table but that is not passed from request.
so it ...
2
votes
2
answers
83
views
PowerShell switch block and values coded in 64 bits
I cannot use a PowerShell Switch statement when 64 bits integers are involved.
I have the follwing PowerShell snippet :
PS D:\> cat .\dirSize.ps1
$dirName = $args[0]
$dirSize = [uint64]( ( dir &...
0
votes
1
answer
41
views
The print statements for my printAnimals method won't stop executing
Whenever my printAnimals method executes, it won't stop repeating whats being printed. I've tried moving the break statements, and changing how the program determines what to print, but so far nothing ...
0
votes
1
answer
44
views
Why does this switch statement (case_else too) not work if I try to forward pipe it?
Why does this work:
est <- unlist(column) %>%
sample(i, replace = TRUE) %>%
matrix(nrow = B, ncol = i) # %>%
est <- switch(param,
"mean" = rowMeans2(...
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 ...
-1
votes
3
answers
54
views
Mysql on duplicate key condition (IF) setting of one field
I am using on duplicate key to update data in a mySQL DB v 8.0.35 (AWS RDS instance)
I want to update a selection of fields with the new value. Plus set a further field (up[dated) to 1 only if a ...
0
votes
0
answers
47
views
The while loop in C++ skips the user input line [duplicate]
If you enter a character as the input for the first question the switch statement should throw you into the default clause, and it does. But after that, the following while loop just keeps running ...
-5
votes
2
answers
136
views
Convert if else statement to a Switch statement
I was responding to a challenge to write C# code taking a if else statement and converting it to a Select statement with all the same outcome. Here is the if else code;
// SKU = Stock Keeping Unit.
//...
2
votes
3
answers
135
views
Convert to a switch statement
How do I convert this to a switch statement? I have tried this a few times. I am not sure what I am missing.
double totalPrice = 0.0;
if (venue.equals("Rod Laver")) {
totalPrice = 225.25 ...
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 = ...