how to go through a string array and apply functions for different strings?
- by Newbie
Ok, this may be really noobish question, but i am wishing there is something i dont know yet.
I go through a file, and check which string each line has, depending on the string value i execute a different function for it (or functions).
This is how i do it now:
if(str == "something"){
// do stuff
}else if(str == "something else"){
// do stuff
}else if(str == "something more"){
// do stuff
}else if(str == "something again"){
// do stuff
}else if(str == "something different"){
// do stuff
}else if(str == "something really different"){
// do stuff
}
I am afraid this will become "slow" after i have to repeat those else if lines a lot...
I tried to use switch() statement, but obviously it doesnt work here, is there something similar to switch() to use here?