May 2018
Intermediate to advanced
412 pages
9h 3m
English
The attribute @type can be used to define new types.
| | @type type_name :: type_specification |
Elixir uses this to predefine some built-in types and aliases. Here are just some of them.
| | @type term :: any |
| | @type binary :: <<_::_*8>> |
| | @type bitstring :: <<_::_*1>> |
| | @type boolean :: false | true |
| | @type byte :: 0..255 |
| | @type char :: 0..0x10ffff |
| | @type charlist :: [ char ] |
| | @type list :: [ any ] |
| | @type list(t) :: [ t ] |
| | @type number :: integer | float |
| | @type module :: atom |
| | @type mfa :: {module, atom, byte} |
| | @type node :: atom |
| | @type nonempty_charlist :: [ char ] |
| | @type timeout :: :infinity | non_neg_integer |
| | @type no_return :: none |
As the list(t) entry shows, you can parameterize the types in a new definition. Simply use one ...
Read now
Unlock full access