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.

1 Answer 1


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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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