0

Is there any way I can use a local parameter within multiple functions? The idea is to save gas when calling functions. A parameter wouldn't have to be copied and be returned every time.

Here's some pseudo code:

function A(uint[] array) public pure returns (uint[]) {
    B(*array);  // send a memory pointer?
    return array;    
}

// B directly manipulates the array via the pointer => see no return value
function B(uint[] *array) internal pure {
    // something
}
  • 3
    I am not sure if I understood you correctly, but as far as I have understood arrays are not copied between function calls, as they can contain millions of elements. They are passed by a reference. Somebody correct me if I am wrong. – Mikko Ohtamaa May 31 '18 at 20:41
  • You're right. I was interpreting the Remix debugger wrong. Thanks. – Chris Jun 1 '18 at 14:39
0

This is solved as Mikko explained in the comment.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.