pragma solidity ^0.4.24; /* One day Chao-chou fell down in the snow, and called out, “Help me up! Help me up!” A monk came and lay down beside him. Chao-chou got up and went away. In this level we learn about arrays The monk reminds you that you don't actually need any help to solve this level. */ contract Test_Arrays_4 is Koans { // You can create arrays of different data types // You can check the lengths of your arrays // Notice the lack of storage specificity generates compiler warnings function test_can_use_arrays_in_Solidity() public { bytes32[] bytesArray; Assert.equal(bytesArray.length, __, "should be an empty bytes array"); uint[] integers; integers.push(12345); Assert.equal(integers.length, __, "should be a nonempty array of uints"); } // Arrays initialization defaults to storage, not memory // Memory arrays only exist in the scope of the current function uint[] storage_array; function test_arrays_need_storage_specification() public { uint[] memory memory_array; memory_array = storage_array; // Notice: storage_array = memory_array is NOT allowed Assert.equal(memory_array, __, "should be the same array"); } // You can declare an immutable, static array uint[1] fixed_array; function test_fixed_arrays() public { fixed_array[0] = 1; Assert.equal(fixed_array[0], __, "should only be able to store 1 uint"); } ...
0.4.18