Simple Assignment Operator
The simple assignment operator(=) assigns the value of the right-hand operand to the left-hand operand.
Example:
uint a;
a = 10; // Assigns the value 10 to the variable a.
Below is the Solidity program to implement a simple assignment operator.
Solidity
// Solidity program to implement // simple assignment operator // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract AssignmentOperators { function basicAssignment() public pure returns (uint) { uint a; a = 10; // a is now equal to 10 return a; } } |
Output:
Solidity – Assignment Operators
Solidity is a high-level, statically-typed programming language for Ethereum smart contracts. Python, JavaScript, and C++ impact it. Solidity has several variable and value assignment operators. Solidity supports the following types of operators:
- Simple Assignment Operator.
- Arithmetic Assignment Operator.
- Bitwise Assignment Operator.
Contact Us