I am a newbie in Solidity. Below is the snippet of code I came across :-
pragma solidity ^0.4.0; contract C { //1
function f(uint len) { // value passed to len = 7 //2
uint[] memory a = new uint[](7); //3
bytes memory b = new bytes(len); //4
// Here we have a.length == 7 and b.length == len a[6] = 8; // 5
}
}
I am unable to understand why (7) is written after new uint[]
in RHS of line 3. Moreover bytes is a data type of fixed length i.e bytes1 , then how did they created a new instance of it with length equal to len
. At last what is meant by this b.length == len a[6] = 8
in line 5 .