Kernel.binary_part
You're seeing just the function
binary_part
, go back to Kernel module for more information.
Specs
binary_part(binary(), non_neg_integer(), integer()) :: binary()
Extracts the part of the binary starting at start
with length length
.
Binaries are zero-indexed.
If start
or length
reference in any way outside the binary, an
ArgumentError
exception is raised.
Allowed in guard tests. Inlined by the compiler.
Examples
iex> binary_part("foo", 1, 2)
"oo"
A negative length
can be used to extract bytes that come before the byte
at start
:
iex> binary_part("Hello", 5, -3)
"llo"
An ArgumentError
is raised when the length is outside of the binary:
binary_part("Hello", 0, 10)
** (ArgumentError) argument error