switch(str) { case "foo": case "bar": case "baz": } --- becomes --- switch(str[0]) { case 'f': switch(str[1]) { case 'o': switch(str[2]) { case 'o': } } case 'b': switch(str[1]) { case 'a': switch(str[2]) { case 'r': case 'z': } } }