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)
quote do
@koans unquote(compiled_name)
def unquote(compiled_name)(answer \\ :nothing) do
def unquote(compiled_name)() do
try do
if answer == :nothing do
unquote(body)
else
unquote(mangled_body)
end
unquote(body)
:ok
rescue
e in _ -> e
end
end
def unquote(compiled_name)(answer) do
try do
unquote(mangled_body)
:ok
rescue
e in _ -> e