牢固地创建一个新的固定大小的数组

时间:2018-08-13 07:22:59

标签: ethereum solidity

下面两个数组有什么区别?

没有df = df.set_index('time') df.d.plot(style='.') 关键字:new

使用bool[3] fixedArray;关键字:new

1 个答案:

答案 0 :(得分:0)

new关键字用于初始化内存中的数组 。从文档中:

  

分配内存阵列

     

在其中创建具有可变长度的数组   可以使用new关键字完成存储。与存储相反   数组,无法通过分配给   .length成员。

pragma solidity ^0.4.16;

contract C {
    function f(uint len) public pure {
        uint[] memory a = new uint[](7);
        bytes memory b = new bytes(len);
        // Here we have a.length == 7 and b.length == len
        a[6] = 8;
    }
}