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:
Edit: I need to use variables outside the if-else-if range inside the if's, updated code:
string s1 = "used";
string s2 = "in";
string s3 = "functions";
if(str == "something"){
something = process(s1, s2);
}else if(str == "something else"){
something = process(s2, s3);
}else if(str == "something more"){
something = process(s1, s3);
something = process(s1, s2);
}else if(str == "something again"){
// do more stuff
}else if(str == "something different"){
// do more stuff
}else if(str == "something really different"){
// do more 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?