Is it common to use switch statements? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Is it common to use switch statements?

I was thinking and i realized that I don't usually use switch. Is it common to use?

13th Mar 2020, 2:47 PM
Felipe Sucupira
Felipe Sucupira - avatar
3 Respostas
+ 14
It depends on how many multiple choices you want to implement in code. Switch case is used to ease up multiple choice options rather than using many if and else statements. So common or not but usage depends on you only.
13th Mar 2020, 2:55 PM
Ketan [#Be Happy šŸ˜„]
Ketan [#Be Happy šŸ˜„] - avatar
+ 3
In a game, if a character has the ability to go North, South, East or West etc. it can be useful.
15th Mar 2020, 1:39 PM
Sonic
Sonic - avatar
0
It depends on how much you want the condition to be, like what sanic said! In a game character has the ability to go south, west, north and east, here I think switch can be the best control structure to implement this action
16th Mar 2020, 3:35 AM
Muhammad Abdulkadir
Muhammad Abdulkadir - avatar