Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The enum keyword can also define a tagged union, which can be viewed as an enhanced enumerated type. A tagged union defines variants instead of values. Each Variant can have zero or more associated types.

Tagged unions are useful in many cases, in particular for defining various & heterogeneous error types for an application. For instance the following code defines an error type and several error variants with nothing in common:

see solution