Since reference types such as arrays are passed by reference by in Solidity, they pass a reference (pointer) to the value. Any change to that value will reflect on original value.
If this is the case, why the changeVar()
function does not change the value of marks array?
pragma solidity ^0.8.0;
contract ref {
uint[] public marks = [1,2,33];
function changeVar() public {
changeVal(marks);
}
function changeVal(uint[] memory _uint) public returns(uint[] memory){
_uint[0] = 111;
}
}