Variant Types

This lesson showcases the main structure of the variant data type.

We'll cover the following

What is a Variant?

A variant allows us to choose between different data types when creating an object. We are not restricted to a single type as we are with an int or string.

In this sense, a variant can be thought of as a type containing mutually exclusive types.

Constructors

The types contained in a variant are not the basic data types provided by Reason. Instead, these types are known as constructors.

Their names can be anything and must always start with a capital letter. We’ll see the inner workings of a constructor in the next lesson.

Get hands-on with 1200+ tech skills courses.