Switch case with boolean or string

Is it possible to use the switch for something other than numbers,

for example a boolean where you just have the cases true and false.

I know I can use IF statements but the whole point of the switch is too have the same functionality with less clutter.

So is it possible?

Yes, you can use a Switch for a boolean.

For TRUE, use CASE 1.
For FALSE, you can use either CASE 0 or the Default Case.

image
image

I see, Thanks. and is there any way to make it work with strings aswell? so with custom words? or do I need to use the IF statement for that.

Yes, it’s better to use the if elseif statement for that

1 Like