The code gives the following error in solidity v0.6 compiler but works fine with compiler v0.5:
TypeError: Member "length" is read-only and cannot be used to resize arrays. nodes.length = 0;
pragma solidity >=0.4.22 <0.7.0;
contract TestNode {
uint[] nodes;
function createNode(uint data) public {
nodes.length = 0; // This line gives the ERROR
nodes.push(data);
}
function pushNode(uint data) public {
nodes.push(data);
}
function getNode() public view returns(uint[] memory) {
return nodes;
}
}
How to convert the code that works with solidity v0.6?