Last active
August 29, 2015 14:08
-
-
Save alco/3eeab282eb9ad3e4245d 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 Returning do | |
defmacro returning(val, do_block) do | |
quote do | |
val = unquote(val) | |
case val, unquote(do_block) | |
val | |
end | |
end | |
end |
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
# this won't work | |
defmodule Returning do | |
defmacro returning(val, do_block) do | |
quote bind_quoted: [val: val, do_block: do_block] do | |
case val, do_block | |
val | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment