diff options
author | Eksperimental <eksperimental@autistici.org> | 2021-12-22 19:24:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-22 20:24:33 +0100 |
commit | c384f19481ade59a651f3ef85c86656db4cf73e2 (patch) | |
tree | e3c85d755d7d39f5ef7ecdb8e4f17f3b17ca7965 | |
parent | bcebc5984d0092479e4d5ca43acf51ff8b2295af (diff) | |
download | elixir-c384f19481ade59a651f3ef85c86656db4cf73e2.tar.gz |
Add note about which attributes support guard notation in typespecs (#11518)
-rw-r--r-- | lib/elixir/pages/typespecs.md | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/elixir/pages/typespecs.md b/lib/elixir/pages/typespecs.md index bb7e3782f..f14be0f70 100644 --- a/lib/elixir/pages/typespecs.md +++ b/lib/elixir/pages/typespecs.md @@ -197,6 +197,8 @@ Type variables with no restriction can also be defined using `var`. @spec function(arg) :: [arg] when arg: var +This guard notation only works with `@spec`, `@callback`, and `@macrocallback`. + You can also name your arguments in a typespec using `arg_name :: arg_type` syntax. This is particularly useful in documentation as a way to differentiate multiple arguments of the same type (or multiple elements of the same type in a type definition): @spec days_since_epoch(year :: integer, month :: integer, day :: integer) :: integer |