Ah, that explains everything! Thank you :)
On Thursday, March 9, 2017 at 6:50:45 AM UTC-5, Michał Muskała wrote:
>
> when is an operator - it behaves very similar to operators like == or in.
>
> iex(1)> quote(do: 1 when 2)
> {:when, [], [1, 2]}
> iex(2)> quote(do: 1 == 2)
> {:==, [context:
when is an operator - it behaves very similar to operators like == or in.
iex(1)> quote(do: 1 when 2)
{:when, [], [1, 2]}
iex(2)> quote(do: 1 == 2)
{:==, [context: Elixir, import: Kernel], [1, 2]}
In case of def, the left side (of the operator) is the call and right the
guards.
Michał.
On 9
If I quote the following:
Code.string_to_quoted """
if foo do
"true"
else
"false"
end
"""
I get the following AST:
{:if, [line: 1], [{:foo, [line: 1], nil}, [do: "true", else: "false"]]}
Which makes sense to me as the last node is a list. However, `when` seems
to follow