mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-30 06:22:32 +03:00
Added documentation on receive do blocks in Elixir.
This commit is contained in:
parent
d8001da799
commit
65f951d87c
@ -369,6 +369,13 @@ spawn(f) #=> #PID<0.40.0>
|
|||||||
# messages to the process. To do message passing we use the `send` operator.
|
# messages to the process. To do message passing we use the `send` operator.
|
||||||
# For all of this to be useful we need to be able to receive messages. This is
|
# For all of this to be useful we need to be able to receive messages. This is
|
||||||
# achieved with the `receive` mechanism:
|
# achieved with the `receive` mechanism:
|
||||||
|
|
||||||
|
# The `receive do` block is used to listen for messages and process
|
||||||
|
# them when they are received. A `receive do` block will only
|
||||||
|
# process one received message. In order to process multiple
|
||||||
|
# messages, a function with a `receive do` block must recursively
|
||||||
|
# call itself to get into the `receive do` block again.
|
||||||
|
|
||||||
defmodule Geometry do
|
defmodule Geometry do
|
||||||
def area_loop do
|
def area_loop do
|
||||||
receive do
|
receive do
|
||||||
|
Loading…
Reference in New Issue
Block a user