diff --git a/lib/elixir/lib/list.ex b/lib/elixir/lib/list.ex index 68a03423489..88677fee28f 100644 --- a/lib/elixir/lib/list.ex +++ b/lib/elixir/lib/list.ex @@ -390,10 +390,10 @@ defmodule List do end @doc """ - Wraps the argument in a list. + Wraps `term` in a list if this is not list. - If the argument is already a list, returns the list. - If the argument is `nil`, returns an empty list. + If `term` is already a list, it returns the list. + If `term` is `nil`, it returns an empty list. ## Examples @@ -407,7 +407,11 @@ defmodule List do [] """ - @spec wrap(list | any) :: list + @spec wrap(nil) :: [] + @spec wrap(list) :: list when list: maybe_improper_list() + @spec wrap(term) :: nonempty_list(term) when term: any() + def wrap(term) + def wrap(list) when is_list(list) do list end