3 ms·
dictionaries generally aren't guaranteed to contain an entry for every possible value of the key type. while you could implement the colors example with a dicti
by sheept 8mo ago
dictionaries generally aren't guaranteed to contain an entry for every possible value of the key type. while you could implement the colors example with a dictionary, ideally you'd want the type system to assure that given a Color, there will be a string associated with it
- vips7L 8mo agoSounds like enums with extra steps.
- epolanski 8mo agoEnums aren't type safe in typescript
- vips7L 8mo agoSounds like a major flaw.
- socalgal2 8mo agoit’s Enuma associated with data without having to repeat yourself If you have to define the Enums in one place and then repeat them all in another just to associate data with each one you’ve failed
- vips7L 8mo agoMaybe you can elaborate but enums in Java or Kotlin easily have data associated with them. enum class Color(val rgb: Int) { RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF) }