Skip to content

Commit

Permalink
Clarify receive docs for unmatched messages (elixir-lang#13076)
Browse files Browse the repository at this point in the history
Update the docs to reinforce that we only operate on "matching messages"
and explicitly call out that unmatched messages remain in the mailbox.
  • Loading branch information
rktjmp authored Nov 5, 2023
1 parent 8d0cbaa commit 4b9ec7b
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/elixir/lib/kernel/special_forms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2300,11 +2300,13 @@ defmodule Kernel.SpecialForms do
defmacro try(args), do: error!([args])

@doc """
Checks if there is a message matching the given clauses
in the current process mailbox.
Checks if there is a message matching any of the given clauses in the current
process mailbox.
In case there is no such message, the current process hangs
until a message arrives or waits until a given timeout value.
If there is no matching message, the current process waits until a matching
message arrives or until after a given timeout value.
Any new and existing messages that do not match will remain in the mailbox.
## Examples
Expand All @@ -2317,8 +2319,8 @@ defmodule Kernel.SpecialForms do
IO.puts(:stderr, "Unexpected message received")
end
An optional `after` clause can be given in case the message was not
received after the given timeout period, specified in milliseconds:
An optional `after` clause can be given in case no matching message is
received during the given timeout period, specified in milliseconds:
receive do
{:selector, number, name} when is_integer(number) ->
Expand Down

0 comments on commit 4b9ec7b

Please sign in to comment.