【发布时间】:2011-02-14 03:26:08
【问题描述】:
在 F# 中,给定以下类:
type Foo() =
member this.Bar<'t> (arg0:string) = ignore()
为什么下面会编译:
let f = new Foo()
f.Bar<Int32> "string"
虽然以下内容无法编译:
let f = new Foo()
"string" |> f.Bar<Int32> //The compiler returns the error: "Unexpected type application"
【问题讨论】:
-
不确定,但是从对 Bar 的调用中删除
不会导致错误。 -
是的,但这有效地使它在内部使用 System.Object。如果您将 typeof 用作某些测试的一部分,那将有点没用。
标签: generics f# pipelining