/// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;
contract StorageToStorageValueTypeAssignment {
? ? // Declare two state variables, stateVar1 and stateVar2, both of type uint.
? ? // Initialize stateVar1 with the value 20 and stateVar2 with the value 40.
? ? uint stateVar1 = 20;
? ? uint stateVar2 = 40;
? ? // In the following function:
? ? // - stateVar1 is assigned the value of stateVar2, which is 40.
? ? // - stateVar2 is updated to the value 50.
? ? // After these operations, stateVar1 holds the value 40, and stateVar2 holds the value 50.
? ? // The function returns the value of stateVar1, which is 40.
? ? function getUInt() public returns (uint) {
? ? ? ? stateVar1 = stateVar2;
? ? ? ? stateVar2 = 50;
? ? ? ? // Returns the value of stateVar1, which is 40 after the assignment.
? ? ? ? return stateVar1;
? ? }
}
// Deploy screenshoot: