4 ms·
I think when you have a mapping of keys to values you really need to have an understanding of what keys are possible (so you don't have an exception accessing t
by robbya 7y ago
I think when you have a mapping of keys to values you really need to have an understanding of what keys are possible (so you don't have an exception accessing the map).
Java enum classes work well for enumerating those, so I end up creating those. These work great so if I use the enum in an if-else sequence the compiler knows if I covered all possible values.
For mappings I instead add a constructor to my enum class so that I can setup the mapping as an instance variable.