Which are the different between binary, String.t, char_list, [char] etc when defining a typespec?
@spec method(binary) :: binary
and
@spec method(String.t) :: String.t
Are they equivalent? Doc says:
- binary Used for Elixir strings.
- char_list Used for Erlang strings. Defined as [char].
String.t
is the same asbinary
, see its definition here.char_list
is more than a plain list of chars. It's defined in theunicode
module in Erlang to be:So it includes both proper and improper lists and the list can contain chars, binaries, or charlists or the empty list.