Current location - Quotes Website - Personality signature - Why Golang (Go language) does not support overloading
Why Golang (Go language) does not support overloading

From a grammatical perspective, overloading expands the function (or method) signature from recognizing only the name to the name + parameter type. Therefore, in this example, you only need to change the foo function with different parameters to different names. Just fine, such as foo1, foo2...

According to the official statement, this is not supported to keep the syntax simple and avoid some problems encountered in the project, such as implicit conversion of parameters, etc.

< p> Languages ??that support overloading also have their reasons. Sometimes, the function or method name is beyond the programmer's control. For example, if Java does not support overloading, there can only be one constructor, which can be constructed through different inputs. Objects are more troublesome and need to be made into a static method create: