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?
Examples:
_from
_id
_amount
_account
How are these different from other variables, and how are they used in events?
[Ethereum] What does “_” mean before a variable name
eventssoliditystate-variable
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.:
There, calling the parameter
totalSupply
would shadow the existing state variabletotalSupply
, so the leading underscore is used to avoid the naming collision.