Variant Constructors
Explore how to declare and use variant constructors in ReasonML, including creating constructors with and without arguments. Understand how to apply switch expressions for effective pattern matching to handle different variant cases in your code.
We'll cover the following...
We'll cover the following...
Constructor Properties
In the previous lesson, we saw a glimpse of a variant’s constructors. A constructor is a special type that uses the basic types available in Reason to create a new value. Its name always starts with a capital letter.
The constructors in a variant are separated by the pipe operator, |. We found a similar use for the | operator in ...