J
Jon Harrop
What is the safest way to make an argv[] comparison? The code below
works.
If you use a language with pattern matching and type inference, like OCaml
or F#, then you can just write:
let () = match Sys.argv with
| [|_; test|] when test = "NKDT" ->
printf "\nComparison is true. Have program do something.\n"
| _ ->
printf "\nComparison is false. Have program do something else.\n"
The catchall pattern handles everything else safely and simply.