Switch Statements

@richard, could you please add switch statements to block coding? it simplifies things like having many tilemaps, so that somebody isnt doing

if (a==1) {

} else if (a==2) {

} else if (a==3) {

} else…

but instead:

switch (a) {

1:

2:

3:

4:

3 Likes

You could just put the tilemaps in an array and then they would all be in order with less code like you’re wishing for.

4 Likes

Wait, that’s a thing?

4 Likes

Yup! Most C-style language have a switch() statement, JavaScript and TypeScript included. Useful … but not as widely used as it probably should be, perhaps because the syntax is a bit quirky.

3 Likes

I’m my game that I’m making, each “case” has a tilemap and something to set the platform speed, player start, etc. that would make it harder to make an array

1 Like

I found out about switch when using Unreal Engine!

It would be so useful for blocks.

1 Like

can makecode still add it? I would find it very useful to have