Created
December 23, 2019 05:02
-
-
Save marsrvr/fe0f7f059e074124b6b5fc7ee21be707 to your computer and use it in GitHub Desktop.
Array demo, static and dynamically sized.
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.5.12; | |
contract ArrayDemo { | |
uint64[] dynamicArray = [1, 2, 3]; | |
uint64[3] staticArray = [1,2,3]; | |
function getDynamicArray(uint64 index) public view returns(uint64){ | |
return dynamicArray[index]; | |
} | |
function setDynamicArray(uint64 newNumber, uint index) public{ | |
dynamicArray[index] = newNumber; | |
} | |
function pushDynamicArray(uint64 newNumber) public{ | |
dynamicArray.push(newNumber); | |
} | |
function getStaticArray(uint64 index) public view returns(uint64){ | |
return staticArray[index]; | |
} | |
function setStaticArray(uint64 newNumber, uint64 index) public{ | |
staticArray[index] = newNumber; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment