Skip to content

Instantly share code, notes, and snippets.

@fishcakez
Forked from josevalim/my_receive.exs
Created March 12, 2014 17:30
Show Gist options
  • Save fishcakez/9511933 to your computer and use it in GitHub Desktop.
Save fishcakez/9511933 to your computer and use it in GitHub Desktop.
defmodule MyReceive do
defmacro my_receive(do: clauses) do
extra = quote do
other -> IO.puts "got #{inspect other}"
end
quote do
receive do: unquote(clauses ++ extra)
end
end
end
defmodule Sample do
import MyReceive
send self, :world
my_receive do
:hello -> IO.puts "hello"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment