[solidity]常用做法

2021-10-21  本文已影响0人  95加不满

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;
}
上一篇 下一篇

猜你喜欢

热点阅读