Original title: "Introduction to Solidity Minimalist: 16. Function Overloading" "
Original author: 0xAA
I am re-learning solidity recently, to consolidate the details, and also write an "Introduction to Solidity Minimalist", For novices (programmers can find other tutorials), 1-3 lectures are updated every week.
All codes and tutorials are open source on github: github.com/AmazingAng/WTFSolidity
Solidity allows functions to be overloaded (overloading), that is, functions with the same name but different input parameter types can exist at the same time, and they are regarded as different functions . Note that solidity does not allow modifier overloading.
For example, we can define both as saySomething( ) functions, one without any parameter, outputs "Nothing"; the other receives a string parameter, and outputs this string.

When calling an overloaded function, the input actual parameter and the variable of the function parameter will be type to match.
If there are multiple matching overloaded functions, the solidity documentation says that an error will be reported. The example it gives is two functions called f(), one parameter is uint8 and the other is uint256. The document says that if you enter 50, it can be converted to uint8 or uint256, so an error will be reported. But I didn't meet:

In this lecture, we introduced the basic usage of function overloading in solidity: the same name But functions with different input parameter types can exist at the same time, and they are regarded as different functions.
Original link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia