I have a couple of questions.
First:
So, In a function, i created memory array. I want to pass this memory by reference to another function..
function test2() public returns(uint a) {
uint[2] memory gio;
gio[0] = 100;
gio[1] = 200;
test3(gio);
return gio[0];
}
function test3(uint[2] storage arr) private returns (uint) {
arr[0] = 35;
}
This doesn't work and says:
Invalid type for argument in function call. Invalid implicit conversion from uint256[2] memory to uint256[2] storage pointer requested. test3(gio); ^-^
Is it not possible ?
Second
internal and private functions are the only types of functions that can receive parameters as reference types, right ? since public and external functions being called could be dependent on another application, so another app can't pass parameters as references. Agreed ?
Third.
string test;
function test2() public returns(uint a) {
test = " awesome ";
test3(test);
return 10;
}
function test3(string storage str) private {
str = " changed ";
}
Why does calling test2
result in:
TypeError: Type literal_string " changed " is not implicitly convertible to expected type string storage pointer. str = " changed "; ^---------^