How can I refer to a specific member of a Tuple of any size in F#

前端 未结 4 1000
囚心锁ツ
囚心锁ツ 2020-12-11 23:54

okay, this might be a silly question.

So I have some tuples of size 4 so like (int,int,int,int)

If it were a 2 tuple I could use fst(myTuple) to refer to th

4条回答
  •  猫巷女王i
    2020-12-12 00:25

    Use pattern matching:

    let tup = 1, 2, 3, 4
    let _,_,third,_ = tup
    printfn "%d" third // displays "3"
    

    This is described directly in the MSDN documentation for tuples: Tuples (F#)

提交回复
热议问题