diff options
author | Adam Bard <github@adambard.com> | 2015-10-18 11:55:53 +0800 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2015-10-18 11:55:53 +0800 |
commit | 29e7a6631e1f413c892197d13835cc374ebeb192 (patch) | |
tree | 20e28ba1db2dee874bce2a3d8573e699de8877a5 | |
parent | 5d8618cac1d55027215a1b778ba731b6434bd927 (diff) | |
parent | 07e04e7a2d0f2b7269e4495c338b039a30f70e64 (diff) |
Merge pull request #1606 from chriszimmerman/elixir-docs
Receive do documentation for Elixir
-rw-r--r-- | csharp.html.markdown | 2 | ||||
-rw-r--r-- | elixir.html.markdown | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/csharp.html.markdown b/csharp.html.markdown index 7aca2c6f..31c0417e 100644 --- a/csharp.html.markdown +++ b/csharp.html.markdown @@ -7,6 +7,7 @@ contributors: - ["Shaun McCarthy", "http://www.shaunmccarthy.com"] - ["Wouter Van Schandevijl", "http://github.com/laoujin"] - ["Jo Pearce", "http://github.com/jdpearce"] + - ["Chris Zimmerman", "https://github.com/chriszimmerman"] filename: LearnCSharp.cs --- @@ -394,6 +395,7 @@ on a new line! ""Wow!"", the masses cried"; ref int maxCount, // Pass by reference out int count) { + //the argument passed in as 'count' will hold the value of 15 outside of this function count = 15; // out param must be assigned before control leaves the method } diff --git a/elixir.html.markdown b/elixir.html.markdown index c8599838..eedeb227 100644 --- a/elixir.html.markdown +++ b/elixir.html.markdown @@ -369,6 +369,13 @@ spawn(f) #=> #PID<0.40.0> # 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 # 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 def area_loop do receive do @@ -384,6 +391,8 @@ end # Compile the module and create a process that evaluates `area_loop` in the shell pid = spawn(fn -> Geometry.area_loop() end) #=> #PID<0.40.0> +# Alternatively +pid = spawn(Geometry, :area_loop, []) # Send a message to `pid` that will match a pattern in the receive statement send pid, {:rectangle, 2, 3} |