[Ethereum] What does “_” mean before a variable name


I'm a beginner, just recently started reading the docs for Solidity.
I can't seem to find this anywhere on google. What does the underscore mean when placed with the indexed keyword?
How are these different from other variables, and how are they used in events?

Best Answer

There's no meaning as far as Solidity is concerned.

Some programmers choose to use a leading underscore for all function parameters, just as a convention to indicate that they're function parameters.

They're also often used so as to avoid collisions, e.g.:

uint256 totalSupply;

constructor(uint256 _totalSupply) public {
    totalSupply = _totalSupply;

There, calling the parameter totalSupply would shadow the existing state variable totalSupply, so the leading underscore is used to avoid the naming collision.

Related Topic