Skip to content

Instantly share code, notes, and snippets.

@0xalpharush
Created May 13, 2022 04:11
Show Gist options
  • Save 0xalpharush/c74adec0444bde79c59c24889b047dc7 to your computer and use it in GitHub Desktop.
Save 0xalpharush/c74adec0444bde79c59c24889b047dc7 to your computer and use it in GitHub Desktop.
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