Hey there,
Is there a way to iterate over a set of values in a mapping?
I have the following mapping:
Address => address => bytes32 => bool.
I'd like to iterate over the array/list of non-zero values of bytes32, given 2 addresses as arguments.
Is that possible?
Dec 17, 2021, 1:34 PM
Python has such command for dictionary for example
Dec 17, 2021, 1:35 PM
I guess there isn't a way such as in python. You could just store the keys inside and array
Dec 17, 2021, 1:41 PM
I thought about it, but it complicates my handling later on
are you sure? is there no built in method as .keys() or .values() or .items() in python? these are very useful functions for a hash table
Dec 17, 2021, 1:55 PM
Yeah, there are no methods for that (as far as I know) usually if you have a unit=>any you could store the max uint and then use it to iterate through the mapping. If your keys aren't uints then I would do something like this https://stackoverflow.com/questions/48898355/soldity-iterate-through-address-mapping
Dec 17, 2021, 2:06 PM