Riding the Camel Deeper into the Desert of Code: Records and Variants
Extending and Encapsulating Data - Records and Variants
Up next on our tour of OCaml are records and variants. If you are familiar with typedef
, struct
, and union
in c/c++, you’ll quickly come to understand how to use records and variants in OCaml. We’ll start off looking at records, how to define them, use them in functions, and automatically generate common functions from our type definitions. There’s more to the eye than what you get in a language like c, so pay close attention as we move through the descriptions below. We’ll break it down one at a time so you’ll have no problems!