Pure
Solidityपरिभाषा
Pure modifier functions को mark करने के लिए use होता है जो न state read करते हैं और न modify करते हैं। Pure functions केवल अपने parameters पर depend करते हैं और external data access नहीं करते। Pure functions को call करना gas-free है (view calls की तरह) जब externally call किया जाए।
English version
The pure modifier is used to mark functions that neither read nor modify state. Pure functions only depend on their parameters and do not access external data. Pure functions are gas-free to call (like view calls) when called externally.
Code Example
// Fonction pure : ne lit ni ne modifie l'état
function add(uint256 a, uint256 b) public pure returns (uint256) {
return a + b;
}
function hash(string memory data) public pure returns (bytes32) {
return keccak256(abi.encodePacked(data));
}
// INVALIDE : accède à l'état
// function getValue() public pure returns (uint256) {
// return value; // ERROR
// }संबंधित पेज
Solingo पर इस concept को practice करें
Pure को interactive exercises और integrated IDE के साथ master करें।
मुफ्त में शुरू करें