Search⌘ K

Object Creation

Explore how to create objects in ReasonML by defining their type, values, and methods. Understand public and private functions, and learn to use the 'this' keyword to access object components for effective object-oriented programming.

The Structure

The structure of an object is very similar to that of a record. A typical object contains three components:

Values

These are the properties of the object. They are defined in the object body using the val keyword. The values of an object cannot be directly accessed from the outside.

Depending on our program, the values of an object can be mutable or immutable.

Public Functions

Public functions are methods which can manipulate and use the object’s values. They can be defined using the ...