Solidity Memory Array

15 pts.
Tags:
Arrays
Smart contracts
I am receiving the "stack too deep" error when compiling my smart contract. I know it has to do with too many variables, and I've heard of creating a memory array to "group" variables together. I'm looking for an example of this in a struct that I can follow. I can post code if it would help. Thanks, Rob
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Yes. However it should be noted that this currently only works with statically sized memory arrays. You can even create an inline memory array in the return statement. Pretty cool, huh?

Example:pragma solidity ^0.4.16;
contract C {
    function f() public pure returns (uint8[5]) {
        string[4] memory adaArr = ["This", "is", "an", "array"];
        return ([1, 2, 3, 4, 5]);
    }
}

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: