Shadowing in Fuctions
pragma solidity 0.8.15;
contract Shadowing {
uint n = 2;
uint x = 3;
function test1() public view returns (uint n) {
return n; // Will return 0
}
function test2() public view returns (uint n) {
n = 1;
return n; // Will return 1
}
function test3() public view returns (uint x) {
uint n = 3;
return n+x; // Will return 3
}
function test4() public view returns (uint) {
return n; // Will return 2
}
}Gotcha!
Last updated