我想使用以下代码来限制只有一个参数.但是,我收到以下错误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."
Run Code Online (Sandbox Code Playgroud)
命令行参数作为数组传递,而不是列表.
如果您只想要一个参数,请执行以下操作:
match argv with
| [|first|] ->
// .... do something with first
| _ -> failwith "Must have only one argument."
Run Code Online (Sandbox Code Playgroud)