3 ms·
It might be confusing as it is different from some other languages, such as C++ and JavaScript. They both evaluate default parameter when the function are calle
by maple3142 5y ago
It might be confusing as it is different from some other languages, such as C++ and JavaScript. They both evaluate default parameter when the function are called.
- orf 5y agoThe difference is neither of these can introspect a functions arguments at runtime. C++ probably doesn’t need to, as it can do it at compile time with templates, but therein lies the difference. Not to say that it can’t is not confusing (at least to begin with), but it’s not an oversight. It’s a conscious choice and I think the only safe one you can make.