Nimony

The road to Nim 3

options

nimony/lib/std/options.nim

This module implements types which encapsulate an optional value.

A value of type Option[T] either contains a value x (represented as some(x)) or is empty (none(T)).

This is the Nimony port. Since exceptions are not yet wired up, get on an empty Option terminates the program (mirroring assert) rather than raising UnpackDefect. Equality is the compiler-provided structural comparison: an empty Option always stores the default value, so two empty Options compare equal and an empty one never equals a populated one.