5
데이터를 튜플이 아닌 단일 값에 바인딩하여 형식의 압축을 해제 할 수 있습니까?OCaml 생성자의 압축을 풉니 다
# 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