如何printfn int * int * int类型

时间:2011-07-08 08:20:39

标签: f#

> (1, 2, 3);;
val it : int * int * int = (1, 2, 3)

> printfn "%d" (1, 2 ,3);;

  printfn "%d" (1, 2 ,3);;
  --------------^^^^^^^

stdin(2,15): error FS0001: The type '('a * 'b * 'c)' is not compatible with any of the types byte,int16,int32,int64,sbyt
e,uint16,uint32,uint64,nativeint,unativeint, arising from the use of a printf-style format string

如何在不创建其他功能的情况下打印此类型?

1 个答案:

答案 0 :(得分:6)

您可以使用格式化程序%A打印任何类型:

printfn "%A" (1, 2, 3);;

否则你需要解压缩你的元组才能打印它,因为没有特定于元组的格式化程序。

相关问题