Here's the code that I have:
int getPos(string partOfSpeech)
{
var pos = 0;
switch (partOfSpeech)
{
case "noun":
pos = 1;
break;
case "verb":
pos = 2;
break;
case "adjective":
pos = 3;
break;
case "Adverb":
pos = 4;
break;
default:
pos = 5;
break;
}
return pos;
}
I would like to simplify this if possible. Is it a valid (and sensible) thing for me to just do a return from inside the switch?