Skip to content

Commit c6ffbe9

Browse files
eksperimentaljosevalim
authored andcommitted
Improve specs and documentation for List.wrap/1 (#7864)
1 parent 473a83b commit c6ffbe9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/elixir/lib/list.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,10 @@ defmodule List do
388388
end
389389

390390
@doc """
391-
Wraps the argument in a list.
391+
Wraps `term` in a list if this is not list.
392392
393-
If the argument is already a list, returns the list.
394-
If the argument is `nil`, returns an empty list.
393+
If `term` is already a list, it returns the list.
394+
If `term` is `nil`, it returns an empty list.
395395
396396
## Examples
397397
@@ -405,7 +405,11 @@ defmodule List do
405405
[]
406406
407407
"""
408-
@spec wrap(list | any) :: list
408+
@spec wrap(nil) :: []
409+
@spec wrap(list) :: list when list: maybe_improper_list()
410+
@spec wrap(term) :: nonempty_list(term) when term: any()
411+
def wrap(term)
412+
409413
def wrap(list) when is_list(list) do
410414
list
411415
end

0 commit comments

Comments
 (0)