Created
May 13, 2022 04:11
-
-
Save 0xalpharush/c74adec0444bde79c59c24889b047dc7 to your computer and use it in GitHub Desktop.
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.8.13; | |
contract Test { | |
struct MyStruct{ | |
uint num; | |
bytes32 info; | |
} | |
MyStruct[] myStruct; | |
function add(uint a, bytes32 b) external { | |
myStruct.push(MyStruct({num: a, info: b})); | |
} | |
function pop() external { | |
if (myStruct.length != 0) { | |
MyStruct[] memory myMemoryStruct = new MyStruct[](1); | |
myMemoryStruct[0] = myStruct.pop(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment