F#:检查值是字符串数组,字符串数组还是字符串 [英] F#: check if a value is an array of strings, an array of arrays of string or a string
本文介绍了F#:检查值是字符串数组,字符串数组还是字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用match
来检查值是字符串数组还是字符串.我尝试了一些徒劳的事情
I need use match
to check if a value is an array of strings or a string. I've tried something in the vain of
| :? string[] -> ..
| :? string -> ..
| :? array<string[]> -> ..
但无济于事.
有帮助吗?
推荐答案
您需要稍微修改语法,但是您几乎是正确的
You need to modify the syntax slightly, but you were almost correct
let fn (arg:obj) =
match arg with
| :? string as str -> printfn "string"
| :? (string[]) as arr -> printfn "string array"
这篇关于F#:检查值是字符串数组,字符串数组还是字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文