-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.sol
50 lines (36 loc) · 1.01 KB
/
array.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
contract Array {
uint[] public arr;
uint[] public arr2 = [1, 2, 3];
//Fixed Sized Array
uint[10] public myFixedSizeArr;
//Get a single array
function get(uint i) view public returns (uint) {
return arr[i];
}
//Get the entire array
function getArr() public view returns (uint[] memory) {
return arr;
}
//Push an object into the array
function push(uint i) public {
arr.push(i);
}
//Remove the last Array
function pop() public {
arr.pop();
}
//Get the length of Array
function getLength() public view returns (uint) {
return arr.length;
}
//Remove a particular Data from the array
//but the length still remains the same just that its set to 0
function remove(uint i) public {
delete arr[i];
}
function examples() external {
uint[] memory a = new uint[](5);
}
}