3 ms·
> 1 is a subset of a smaller issue. Default params are just a way to declare variadic functions more easily, but the language doesn't allow variadic functions a
by masklinn 9y ago
> 1 is a subset of a smaller issue. Default params are just a way to declare variadic functions more easily, but the language doesn't allow variadic functions at all. In go trying to define `add(int x, int y)` and `add(float64 x, float64 y)` is a compile error, even though the compiler can tell full well which one I want to use where.
That's function overloading rather than variadic functions. Variadic would be `add(xs int..)` where you can pass in any number of int, and they'll be collected into a slice or whatever.