Skip to content

Commit aa108eb

Browse files
authored
Fix docs for Process.monitor/2 (#14009)
Previously, the example contained 2 issues. 1. A syntax error on `receive` as there were no parens. 2. The example was incomplete, and would hang on the 2nd receive This commit updates the example to reflect the original intent, by sending 2 messages and getting a `:noproc` on the 2nd `receive`.
1 parent fb4b1ff commit aa108eb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/elixir/lib/process.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,15 @@ defmodule Process do
569569
570570
send(pid, {:ping, ref_and_alias})
571571
572-
receive do: msg -> msg
572+
receive do: (msg -> msg)
573573
#=> :pong
574574
575-
receive do: msg -> msg
575+
ref_and_alias = Process.monitor(pid, alias: :reply_demonitor)
576+
#=> #Reference<0.906660723.3006791681.40191>
577+
578+
send(pid, {:ping, ref_and_alias})
579+
580+
receive do: (msg -> msg)
576581
#=> {:DOWN, #Reference<0.906660723.3006791681.40191>, :process, #PID<0.118.0>, :noproc}
577582
578583
"""

0 commit comments

Comments
 (0)