Split koan into two functions with different arity

This commit is contained in:
Felipe Sere
2016-03-10 23:16:24 +00:00
parent eb1da4b1fc
commit a6bcd89e7a

View File

@@ -4,13 +4,18 @@ defmodule Koans do
mangled_body = ASTMangler.expand(body, quote do: answer) mangled_body = ASTMangler.expand(body, quote do: answer)
quote do quote do
@koans unquote(compiled_name) @koans unquote(compiled_name)
def unquote(compiled_name)(answer \\ :nothing) do def unquote(compiled_name)() do
try do try do
if answer == :nothing do unquote(body)
unquote(body) :ok
else rescue
unquote(mangled_body) e in _ -> e
end end
end
def unquote(compiled_name)(answer) do
try do
unquote(mangled_body)
:ok :ok
rescue rescue
e in _ -> e e in _ -> e