ソロidity-3.定数
768 ワード
定数(constant state variables)は、すべてのタイプが定数をサポートしているわけではなく、現在サポートされているのは をしなければならない。コンパイラは を残しておくことはできません。
関数は、ブロックチェーン上の任意の状態を変更しないことを約束します。
は、constant
として定義されてもよく、javaのstatic静的変数と同様に、定数は以下のように規定されています。
および
だけである。constant
は、コンパイル中に1つの表現による値付けconstant
のためにstorage
に空間pragma solidity ^0.4.0;
contract C {
uint constant x = 32**22 + 8;
string constant text = "abc";
bytes32 constant myHash = keccak256("abc");
}
常関数(Content Functions)関数は、ブロックチェーン上の任意の状態を変更しないことを約束します。
pragma solidity ^0.4.0;
contract C {
function f(uint a, uint b) constant returns (uint) {
return a * (b + 42);
}
}