Is there a mistake in funcB? I do not understand why/when to mention the variable name of the return parameter in the function signature.
contract Foo {
// State variables go to Storage
uint[] public foo;
function funcA(uint[] x) public returns (uint) { // x is in memory
foo = x // x is copied to storage now
uint a = 100 // a is in storage
return a
}
function funcB(uint[] x) public returns (uint a) { // x is in memory
a = 100 // a is in memory? because `returns (uint a)`
return a
}
}
Also, I suppose funcA is incorrect but funcB is okay in the following example?
contract Foo {
uint[] public foo;
function funcA() public returns (uint[]) {
uint a[];
// push stuff to a
return a
}
function funcB() public returns (uint a[]) {
// push stuff to a
return a
}
}