2017-08-04 7 views
2

重複してご質問申し訳ございません。 "_"演算子は何をしますか?Ethereumからのオペレータ_;

このコードはイーサリアム契約書からです: https://ethereum.org/token#deploying

contract owned { 
    address public owner; 

    function owned() { 
     owner = msg.sender; 
    } 

    modifier onlyOwner { 
     if (msg.sender != owner) throw; 
     _; 
    } 

    function transferOwnership(address newOwner) onlyOwner { 
     owner = newOwner; 
    } 
} 
+1

あなたは、答えでは詳しい説明と例を参照することができます。 https://ethereum.stackexchange.com/questions/5861/are-underscores-in-modifiers-code-or-are-they-just-meant-to-look-cool?newreg=95181540ee304308aa071f6a2b97d87f – Dez

答えて

0

それを修飾内部で使用されています。

" 修飾子の定義で特殊記号" _ "が表示されている場所に関数本体が挿入されています。

参考: Contracts — Solidity 0.4.19 documentation

そして、それは一度だけ修飾子で使用される場合には、次のようにそれを見ることができます:戻り変数が割り当てられた後 を、_があるものに制御フローを返します現在のモディファイアの隣にあります(現在のモディファイアの隣は次のモディファイアまたは関数になります)。あなたの質問は、この他のサイトで解決され Are underscores _ in modifiers code or are they just meant to look cool?

関連する問題