Immutable variables are like constants. Values of immutable variables can be set inside the constructor but cannot be modified afterwards.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract Immutable {
// coding convention to uppercase constant variables
// 상수변수의 코딩 컨벤션은 대문자다.
address public immutable MY_ADDRESS;
uint public immutable MY_UINT;
constructor(uint _myUint) {
MY_ADDRESS = msg.sender;
MY_UINT = _myUint;
}
}
Solidity - Ether and Wei (0) | 2022.12.22 |
---|---|
Solidity - Reading and Writing to a State Variable (0) | 2022.12.21 |
Solidity - Constants (0) | 2022.12.21 |
Solidity - Variables (0) | 2022.12.21 |
Solidity - Primitive Data Types (0) | 2022.12.19 |