Quantcast
Channel: Flexible switch case syntax - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by nhouser9 for Flexible switch case syntax

$
0
0

You could use .split("") on the input string to split it into an array of strings where each element in the array was a word in your original string. In other words

"ADD C She".split("") = {"ADD", "C", "She"}

Once you have an array you can easily check element 1 for the command name with a switch statement, element 2 for the file name, and element 3 for the argument.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>