0

I have a

mapping(address => string[]).

How can I check if, given an address and a position of the array string[] corresponding at that address, it exists a value in that position or not?

Thank you.

0

If I understand your problem well, you just want to know if the index given is valid, i.e not bigger than the array's length.

function check_index(address addy, uint256 index) view returns (bool) {
    return (my_mapping[addy].length > index);
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.