小编Ale*_*don的帖子

为什么签名是...... - >结果<char*string>?

我正在关注斯科特的讲话,他带来的一个例子是:

type Result<'a> = 
    | Success of 'a
    | Failure of string
let pchar (charToMatch, input) =
    if System.String.IsNullOrEmpty (input) then
        Failure "no input!"
    else
        let first =  input.[0]
        if  first = charToMatch then
            let remaining = input.[1..]
            Success (charToMatch, remaining)
        else
            let msg = sprintf "exepecting '%c' got '%c'" charToMatch first
            Failure msg
Run Code Online (Sandbox Code Playgroud)

Visual Studio代码显示该pchar函数的签名是:

char*string->Result<char*string> :

vscode截图

退货类型应该只是Result<'a>

.net f#

2
推荐指数
1
解决办法
78
查看次数

标签 统计

.net ×1

f# ×1