Steps
Steps to learning Reason OCaml

Myer Nore
Mar 2, 2018 - 2 min read

Objects

How is an Object different from a Record?

Here is an example that declares a Record and compares it with the equivalent Object definition.

/* loading */

What are Objects used for?

Many people do not know what leeks are good for in cooking, so there is a proverb: "An onion too strong, a chive too weak? Don't be afraid to use a leek." Similarly, in ReasonML, many people don't quite know what to do with Reason Objects.

A History of OCaml, reports that OCaml was originally CAML, or Categorical Abstract Machine Language, and a variant called emerged in 1996 called Objective Caml that, in 2011, became known as OCaml. Objects were added to OCaml / ReasonML to bring Object Oriented Programming / OOP into the language.

Like Records and Tuples, and they group attributes into a data structure. Unlike Records, they have a concept of private and public methods, and can hide state inside. Unlike Tuples, the attributes are named and unordered. Perhaps we should say, "A record too rigid, a tuple too direct? Don't be afraid to use an object."

Image Credit: Objects by kim anh on Flickr

Edit this post here