O'Reilly logo

Programming Elixir by Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Specifying a Type

A type is simply a subset of all possible values in a language. For example, the type integer means all the possible integer values, but excludes lists, binaries, PIDs, and so on.

The basic types in Elixir are any, atom, char_list (a single-quoted string), float, fun, integer, map, none, pid, port, reference, and tuple.

The type any (and its alias, _) is the set of all values, and none is the empty set.

A literal atom or integer is the set containing just that value.

The value nil can be represented as [] or nil.

Collection Types

A list is represented as [type], where type is any of the basic or combined types. This notation does not signify a list of one element—it simply says that elements of the list will be of the given ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required