Elixir type spec for a function with default parameters

半腔热情 提交于 2019-12-23 09:01:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!