Solidity - Comments


Advertisements

Solidity supports both C-style and C++-style comments, Thus −

  • Any text between a // and the end of a line is treated as a comment and is ignored by Solidity Compiler.

  • Any text between the characters /* and */ is treated as a comment. This may span multiple lines.

Example

The following example shows how to use comments in Solidity.

function getResult() public view returns(uint){
   // This is a comment. It is similar to comments in C++

   /*
      * This is a multi-line comment in solidity
      * It is very similar to comments in C Programming
   */
   uint a = 1;
   uint b = 2;
   uint result = a + b;
   return result;
}
Advertisements