Created
January 31, 2022 10:44
-
-
Save ZakriaJanjua/830208f7aac5eb6c1e0c9433bddde340 to your computer and use it in GitHub Desktop.
Arrays and 2dArrays in solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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