1

Is there any way to store the values like we store in Python using a dictionary? for eg: there are 5 states and a single address. I want to store these states as

my_pair = {'state_one id': 'address ','state_two id': 'address'}

Note: Address remains the same only the state_id is changing.

3

Check out mappings. You declare the key type and the value type as such

mapping(uint => address) my_pair; my_pair[0] = 0x123 address currentState = my_pair[0];

Now currentState holds 0x123.

  • Note: You should be aware that the key is not stored in the mapping. – Ismael Sep 25 '17 at 16:42

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.