For example in this typespec for module String:
@spec validate(String.t) :: {:atom}
What does it mean? and how can I test it through iex
?
** (UndefinedFunctionError) function String.t/0 is undefined or private
(elixir) String.t()
Update
Looks like some people dont see the necessity of testing which is the type of something through iex
For the rest of us who are learning elixir we can do it like this:
iex(8)> t String
@type t() :: binary()
@type codepoint() :: t()
@type grapheme() :: t()
@type pattern() :: t() | [t()] | :binary.cp()
iex(9)> t(String)
@type t() :: binary()
@type codepoint() :: t()
@type grapheme() :: t()
@type pattern() :: t() | [t()] | :binary.cp()
Also for the .t
If you want to refer to the “string” type (the one operated on by functions in the String module), use String.t/0 type instead.