Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active March 31, 2020 13:45
Show Gist options
  • Save agoiabel/ae2c0f56c259e6a0049da26b1acd6c96 to your computer and use it in GitHub Desktop.
Save agoiabel/ae2c0f56c259e6a0049da26b1acd6c96 to your computer and use it in GitHub Desktop.
pragma solidity ^0.5.3;
contract{
uint[] myArray;
function manipulateArray() external {
myArray.push(1); // add an element to the array
myArray.push(3); // add another element to the array
myArray[0]; // get the element at key 0 or first element in the array
myArray[0] = 20; // update the first element in the array
//we can also get the element in the array using the for loop
for (uint j = 0; j < myArray.length; j++) {
myArray[j];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment