I have the following in my contract:
struct familyMember {
bool isParent;
string name;
uint balance;
bool active;
uint spendLimit;
address accountNumber;
}
mapping (address => familyMember) familyMembers;
address[] public familyMemberAccounts;
I have the following function I want to use to check if a mapping exists for a given struct:
function checkFamilyMember(address _address) private view returns (bool) {
bool familyMemberExists = false;
if (bytes(familyMembers[_address].name).length != 0) {
familyMemberExists = true;
}
return familyMemberExists;
}
I don't think this is working as intended but am not sure how I can debug. I would normally use a console.log() but I dont think I can do this in Remix.
Is this a correct way to check if mapped struct exists or is there a better way? I did not see any recent answers (I am using version 0.8.0). This answer is 4 years old, so I wanted to know if there might be a new way.
I just wanted to see if there have been any new ways to handle this in the last 4 years since solidity is changing so much. Thanks!
– joselvelez May 12 '21 at 05:13