lets say I have 5 values: "hello", "good bye", "so long", "farewell", "good night"
and i'm looking for 3 values in those 5. should I use switch or if/else. and in this example its 5. but in reality its like 50 values and i am looking for 30 values.
does switch mean that it is only a set amount values and should I just use 3 if else
so basically
if(value = "hello")
{do stuff}
else if(value = "good bye")
{try stuff}
else if (value = "so long")
{act now}
or
switch(value)
case "hello":
do stuff
case "good bye":
try stuff
case "so long":
act now
default:
no actions
or
if(value == "hello"){
do stuff
}
if(value == "good bye"){
try stuff
}
if(value == "so long"){
act now
}
i'm getting all 5 values but I only need to act for 3 of those values. now again this is a small example the real world use case has 50 values but I only need to act on 25 to 30 values.
Aucun commentaire:
Enregistrer un commentaire