Hello Guys!
I need a bit of assistance. I think I have already overthought it.
Here is my code, think it’s simple enough.
pragma solidity 0.8.0;
pragma abicoder v2;
contract EntityArray {
struct Entity {
uint data;
address _address;
}
Entity[] public entityStructs;
function addEntity(uint data, address _address) public returns (Entity[] memory){
Entity memory newEntity;
newEntity._address = _address;
newEntity.data = data;
entityStructs.push(newEntity);
return entityStructs;
}
function deleteEntity() public returns (Entity[] memory){
entityStructs.pop();
return entityStructs;
}
}
What I want to do is remove the last element of the Struct Array (this means removing an address) with the deleteEntity function, but it’s not deleting it. What am I missing? Create Entity works just fine.
Any help as always is appreciated.
Thank you!