Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Elixir does not have a separate set of operators for floats and integers, so you would not be able to infer which type of number the variable needs to be.

Elixir doesn't care; it'll convert to a float if necessary (namely, if one of the arguments is a float):

    iex(1)> 1 * 1.0
    1.0
This is identical to the behavior of e.g. Julia:

    julia> 1 * 1.0
    1.0
> The most optimal solution in my opinion would be a type annotation for the function

My point is that the type annotations are redundant, at least in this particular case; the acceptable types are already obvious from the function definition itself.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: