美文网首页
[solidity]常用做法

[solidity]常用做法

作者: 张亚伦 | 来源:发表于2021-10-21 15:16 被阅读0次

    Summary:

    • Dynamic arrays are only available in storage, not in memory.
    1. Concatenating arrays
    function ConcatenateArrays(address[] Accounts, address[] Accounts2) returns(address[]) {
        address[] memory returnArr = new address[](Accounts.length + Accounts2.length);
    
        uint i=0;
        for (; i < Accounts.length; i++) {
            returnArr[i] = Accounts[i];
        }
    
        uint j=0;
        while (j < Accounts.length) {
            returnArr[i++] = Accounts2[j++];
        }
    
        return returnArr;
    }
    

    相关文章

      网友评论

          本文标题:[solidity]常用做法

          本文链接:https://www.haomeiwen.com/subject/pthtaltx.html