【发布时间】:2013-06-27 20:50:57
【问题描述】:
如果我声明这个 F# 函数:
let extractColumn col (grid : List<Map<string, string>>) =
List.map (fun row -> row.[col]) grid
编译器抱怨:
错误 FS0752:运算符 'expr.[idx]' 已根据此程序点之前的信息用于不确定类型的对象。考虑添加更多类型约束
为 lambda 的 row 参数添加类型注释修复它:
let extractColumn col (grid : List<Map<string, string>>) =
List.map (fun (row : Map<string, string>) -> row.[col]) grid
为什么不能从extractColumn函数的grid参数中得到row的类型?
【问题讨论】:
标签: f# type-inference type-annotation