क्या टुपल के बजाय अपने डेटा को एक मान पर बाध्य करके एक प्रकार को अनपैक करना संभव है?ओकैमल कन्स्ट्रक्टर अनपॅकिंग
# type foo = Foo of int * string;;
type foo = Foo of int * string
# Foo (3; "bar");;
Foo (3; "bar");;
Error: The constructor Foo expects 2 argument(s),
but is applied here to 1 argument(s)
# Foo (3, "bar");;
- : foo = Foo (3, "bar")
# (* Can this possibly work? *)
# let Foo data = Foo (3, "bar");;
let Foo data = Foo (3, "bar");;
Error: The constructor Foo expects 2 argument(s),
but is applied here to 1 argument(s)
# (* Here is the version that I know works: *)
# let Foo (d1, d2) = Foo (3, "bar");;
val d1 : int = 3
val d2 : string = "bar"
क्या यह वाक्य रचनात्मक रूप से संभव है?
संभावित डुप्लिकेट [केवल एक टुपल मान के साथ एक प्रकार प्रकार का कन्स्ट्रक्टर का उपयोग करना] (http://stackoverflow.com/questions/9774671/using-a-variant-type-constructor-with-just-one-tuple-value) – ygrek