I am puzzled at how template matching works in F # for let. I am using the Visual Studio "F # interactive" window, F # version 1.9.7.8. Let's say we define a simple type:
type Point = Point of int * int ;;
and trying to match the pattern with values Pointwith let.
let Point(x, y) = Point(1, 2) in x ;;
not working with error FS0039: The value or constructor 'x' is not defined. How are you supposed to use pattern matching with let?
The most interesting thing is that:
let Point(x, y) as z = Point(1, 2) in x ;;
returns 1 as expected. Why?
source
share