问题
How do I write a type spec for the function that accepts, let's say, one parameter which has a default value? Something like the following:
def foo(bar \\ 10) do
bar
end
Would it be this:
@spec foo(integer) :: integer
Or what would it be?
Thank you.
回答1:
Yes.
I would add that if your question is if there is a difference between the typespec of a function which has an argument with a default value and an argument that doesn't, then no there is no difference.
来源:https://stackoverflow.com/questions/37396853/elixir-type-spec-for-a-function-with-default-parameters