Solidity - 註釋



Solidity 同時支援 C 式和 C++ 式註釋,因此 -

  • 在 // 和行尾之間的任何文字都被視為註釋,並且被 Solidity 編譯器忽略。

  • 在 /* 和 */ 字元之間的任何文字都被視為註釋。這可能會跨越多行。

示例

以下示例演示如何在 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;
}
廣告
© . All rights reserved.