F#定义方法参数

……类定义略
member x.Go(a,b)="a is " + a + " and b is " + b
member x.Go1 a b ="a is " + a + " and b is " + b
F#中(x,y)是有特别的意义的 这种东西叫做 元组(Tuples)
当 Go(a,b)时,定义函数的参数为一个元组
而 Go1 a b 时,是2个参数
调用时也不同(new对象略)
    printfn "%A" (t1.Go("aaa","bbbb"))
    ("aaa","bbbb") |> t1.Go |> printfn "%A"

    printfn "%A" (t1.Go1 "x" "y")
    "y" |> t1.Go1 "x"|> printfn "%A"
posted @ 2013-05-03 17:16  czcz1024  阅读(160)  评论(0编辑  收藏  举报