我想使用以下代码来限制只有一个参数。但是,我在 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."
最佳答案
命令行参数作为数组传递,而不是列表。
如果您只期望一个参数,请执行以下操作:
match argv with
| [|first|] ->
// .... do something with first
| _ -> failwith "Must have only one argument."
关于f# - 简单解析命令行参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20252167/