Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/elixir/lib/list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a native speaker, but this sentence feels strange. "... if it is not already a list." might read better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good catch. Looks like a typo.


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

Expand All @@ -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
Expand Down