Skip to content

Instantly share code, notes, and snippets.

@tosik
Created December 26, 2014 08:51
Show Gist options
  • Save tosik/7207264c79f25b59c494 to your computer and use it in GitHub Desktop.
Save tosik/7207264c79f25b59c494 to your computer and use it in GitHub Desktop.
defmodule Foo do
def loop do
receive do
{:hello, msg} ->
IO.puts msg
loop
{:world, _} ->
IO.puts "bad"
loop
end
end
end
pid = spawn fn -> Foo.loop end
send pid, {:hello, "world1"}
send pid, {:hello, "world2"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment