I am writing a Processing script and want to detect whether a key (using the key variable) is one of a set of keys chosen by the user ahead of time (say, in a settings JSON file or some other method). I used a switch/case statement to set this up, but it turns out I cannot use variables as case expressions.
I have used the final keyword to mark them as constants, and this works for those defined as direct variables, but not those stored inside an array.
Is there a way of doing this to avoid either using a long if/elseif statement or splitting the array into multiple variables?
Aucun commentaire:
Enregistrer un commentaire