4 ms·
Elixir doesn't technically have default arguments, and this isn't such a pedantic distinction since what it has is a macro that defines a whole other function.
by sodapopcan 3y ago
Elixir doesn't technically have default arguments, and this isn't such a pedantic distinction since what it has is a macro that defines a whole other function.
defmodule Foo do
def bar(baz \\ "baz") do
baz
end
end
becomes
defmodule Foo do
def bar do
"baz"
end
def bar(baz) do
baz
end
end
Which, as you pointed out, are two completely separate functions.
- giraffe_lady 3y agoAhh that makes so much sense, I feel like I should have guessed something like that was going on. Thanks!