I want to use the following code to restrict there is only one argument. However, I got the following error at first :: NIL
?
Error 1 This expression was expected to have type string [] but here has type 'a list
[<EntryPoint>]
let main argv =
match argv with
| first :: NIL ->
.... do something with first
| _ -> failwith "Must have only one argument."
The command line arguments are passed as an array, not a list.
Do something like this if you expect exactly one argument:
match argv with
| [|first|] ->
// .... do something with first
| _ -> failwith "Must have only one argument."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With