This State on Ethereum: When using “Constant” and ”
When to use “Constant” and Non -wiever ”in Ethereum
Stubborn trumpets should be demolished when attempting to try to be „permanent” i „readable” keywords when attempting to attempt at the Ethereum blockchain. In this state, we dispel the intervals of these two keywords and the projected walls in which one of them comes.
Post -Welded keyword
The „permanent” keyword is used to express exit, which do not follow the later initiative. These expirations can be used for screening, cache or other Foles, an unnatural meaning in the state of contract service.
`
// uint256 Public permanent minimum_usd = 50 * 1E18;
`
Here are some walls where the „storage” field:
- Constant: If you need to pull the concrete value that do not change over time, use the „constant”.
- Data -Croever: If the anti -active cache must often access the values, use the „constant”.
- Constant retrieval: Constant properation of functions by using „constant”.
Unnatural keyword
The „non -sensitive” keyword is used to express matures that no one can be changed after the initiation. They were not named on Dysen and do not need to be changed after creation.
`
// uint256 public unchanged minimum_usd;
`
Here are some walls in which the „anonymous” reflects:
- Constant: If you need to determine the constants, use the „immutable”.
- Create non -consuming structures: If you use the structure and want to kill you, the fields cannot be changed after creating, use „no existence”.
- Ochran at the expiry of the maturity: Expiration stocks for student changes for the use of „unusual”.
Key Palse Display
Here are the key -do -do constant
and non -state ‘:
|
Keyword |
This |
The USPolzing Version |
| — — —
| Constant
| Situation, cache, constant retrieval | Combine constant values that do not change with time. |
| `Not pressed ‘| Unusual maturity that cannot be changed after initialization Create anonymous structures or roasted parts to predict students. |
In conclusion, use the „storage” keyword to comb the data permanent or cash, which are not called in the state of contract service. Using the „anonymous” keyword to create anonymous parties that do not follow the later initiative.
It plans these manually growing prints and better projects to use „constant” and „unchanged”, you can write, read and serve the blockchain more effectively.