I have a function like this(foo): I need to compare the input string and perform a task accordingly . Task is same, but only for a selected set of values. For all other values do nothing.
function foo(string x)
{
if(x == "abc")
//do Task1
if(x == "efg")
//do Task1
if(x == "hij")
//do Task1
if(x == "lmn")
//do Task1
}
Is there any other means to do checking other than this? Or putting OR
operator inside if
?
What is the preferred way?