Skip to content

Type introspection

boolean?(value)

Return true when the given value is a boolean.

float?(value)

Return true when the given value is a float.

integer?(value)

Return true when the given value is a integer.

list?(value)

Return true when the given value is a list.

map?(value)

Return true when the given value is a map.

number?(value)

Return true when the given value is a number (an integer or a float)

Examples:

iex> number?(1.1)
true
iex> number?(10)
true
iex> number?("lala")
false

string?(value)

Return true when the given value is a string.

tuple?(value)

Return true when the given value is a tuple.

typeof(v)

Return the type of the given argument, as a string

Examples:

iex> typeof "hello"
"string"
iex> typeof [1, 2, 3]
"list"
iex> typeof %{type: "x"}
"map"
iex> typeof {1, 2}
"tuple"
iex> typeof true
"boolean"
iex> typeof nil
nil
iex> typeof 1.1
"float"
iex> typeof 10
"integer"