Don't Understand Default Case in Switch Statement

I don’t understand how the default activity is supposed to work in Switch.

My statement returns a string. I made sure that the type is string.

I have three case statements, one for “A”, “B”, and “C” for example.

I should only receive those three values, and if I do not, then I want to throw an exception. So I put my exception in the Default case, but as it is first, it throws it every time. This doesn’t make sense to me.

I want to have something like an “Else” case, if there are no other matches then do this…

Thanks,

Bryan

That is how it should work, default is when none of the conditions are met. see this example, if the user selects a name that i do not have a case for, then it does the default activities. One thing to note is that you do not need quotes around the values for each case…
image

Expression is the variable assigned to the selection from the user.
The case are the string values i am looking for in the condition without quotes. It is funny because you need quotes for string values everywhere else.

That is odd indeed :slight_smile:

I made a mistake. In my case statements I had “A” instead of A, and “B” instead of B. That is a little tricky. It works now.

Sure thing, i dont blame you, i remember when i first used this activity, had the exactly same problem than you with the default coming first always :joy:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.