12/21/2017 - 2:05 PM

Moose Types

This miniature type system allows you to define types for attributes.

There are built-in ones like Str, Num, Bool, HashRef etc. In addition, every class name in your program can also be used as a type name. Finally, you can even create custom types, whether its subtypes or entirely new types. For example, you could define the type PosInt, a subtype of Int which would only allow positive numbers