3
我对模式匹配如何在F#中工作let
感到困惑。我正在使用Visual Studio'F#interactive'窗口,F#版本1.9.7.8。假设我们定义了一个简单类型:F#模式匹配
type Point = Point of int * int ;;
,并使用let
的尝试模式匹配反对Point
值。
let Point(x, y) = Point(1, 2) in x ;;
因为error FS0039: The value or constructor 'x' is not defined
而失败。一个人应该如何使用与let
模式匹配?
最奇怪的是:
let Point(x, y) as z = Point(1, 2) in x ;;
收益1预期。为什么?