1

Can i do reverse mapping in solidity language.

for example:

case 1 : mapping(address=>uint256) ----- mapping

case 2: mapping(uint256=>address) ------reverse mapping

can we perform case 2 in solidity successfully?

3

Yes, a mapping(uint256=>address) is valid.

Mapping types are declared as mapping(_KeyType => _ValueType). Here _KeyType can be almost any type except for a mapping, a dynamically sized array, a contract, an enum and a struct. _ValueType can actually be any type, including mappings.

But, if the value of the first mapping is a mapping or struct, then a reverse mapping would not be possible.

See the source (Solidity docs) for more information.

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.