0

In a contract where a modifier like this would be reused a lot, is ID inherited by the function that uses the modifier? If not, this check would need to be in the function. If yes, is there any drawbacks from putting uint ID in the modifier?

modifier isMember (address _foo) {
  uint ID = memberIndex[_foo];
  require(ID != 0); 
  _;
}
1

No, a function cannot access the variables in the modifier.

The compiler will show an error

DeclarationError: Undeclared identifier.
        uint b = ID;
                 ^
| 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.