0

I really can't figure out whats wrong with this function, its probably something stupid but I can't see it. Thanks.

function duplicatefinder(mapping exists, uint256 intermediate, uint256[] expandedValues) internal pure {
        if(exists[intermediate] == false){
            expandedValues[i] = intermediate;
            exists[intermediate] = true;
        } else {
            intermediate += 1 % 20;
            duplicatefinder(exists, intermediate, expandedValues);
        }
    }
0

Well you cannot pass whole mapping as a function parameter. To work with mappings you should already have them declared and then in the function you can pass the key mapping key, something like this:

mapping (uint256 => bool) exists;

function duplicatefinder(uint256 intermediate, uint256[] expandedValues) internal pure {
    if (exists[intermediate] == false) {
        // do something ...
    }
}

If you need to pass dynamic list of data then you can maybe use array as function parameter.

2
  • Thank you, I have fixed my problem with your advice! Jan 13 at 14:17
  • Happy to help. You can accept my answer as correct so others having the same issue can recognize the solution. Jan 13 at 14:19

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.