Skip to content

Instantly share code, notes, and snippets.

@ZakriaJanjua
Created January 31, 2022 10:44
Show Gist options
  • Save ZakriaJanjua/830208f7aac5eb6c1e0c9433bddde340 to your computer and use it in GitHub Desktop.
Save ZakriaJanjua/830208f7aac5eb6c1e0c9433bddde340 to your computer and use it in GitHub Desktop.
Arrays and 2dArrays in solidity
pragma solidity >=0.7.0 <0.9.0;
contract MyContract {
uint[] public intArray = [1,2,3];
string[] public stringArray = ["a","b", "c", "d"];
string[] public values;
uint[][] public my2dArray = [ [1,2,3,4], [5,6,7,9] ];
function pushValues(string memory _value) public {
values.push(_value);
}
function viewValues() public view returns (uint) {
return values.length;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment