3 ms·
Lambad definitions don't take arguments, they jump straight to argument matching. Take: case value do true -> "true" false -> "false" _
by sodapopcan 3y ago
Lambad definitions don't take arguments, they jump straight to argument matching.
Take:
case value do
true -> "true"
false -> "false"
_ -> "uh..."
end
vs
fn
true -> "true"
false -> "false"
_ -> "uh..."
end
`do` is simply syntactic sugar for a keyword list argument containing a `:do` key:
if(true, [{:do, "hi there"}])
So it wouldn't make sense for `fn` to take a `do`.
- throwawaymaths 3y agofn do true -> "true" false -> "false" _ -> "uh..." end
- sodapopcan 3y agoAs much as I despise people responding in pure code, you're right, it's technically `fn/1` [0]. Even though the docs say `fn(clauses)`, `cond/1`, which requires the `do`, also says `cond(clauses)` [1] so looks like I'm wrong. [0] https://hexdocs.pm/elixir/1.14/Kernel.SpecialForms.html#fn/1 https://hexdocs.pm/elixir/1.14/Kernel.SpecialForms.html#fn/1 [1] https://hexdocs.pm/elixir/1.14/Kernel.SpecialForms.html#cond/1 https://hexdocs.pm/elixir/1.14/Kernel.SpecialForms.html#cond...