-
-
Save fishcakez/9511933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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