2013-10-21 16 views

答えて

7

`および[]構文は、多型のバリアントを定義するためのものです。インラインバリアント定義と似ています。あなたのケースでは

http://caml.inria.fr/pub/docs/manual-ocaml-4.00/manual006.html#toc36

、dirが ``買うか売る値を取ることができ、パターンマッチングはそれに応じて動作します:

let x = { dir = `Buy, quantity = 5, price = 1.0, cancelled = true } 

match x.dir with 
| `Buy -> 1 
| `Sell -> 2 
関連する問題