4 ms·
> Your guess is as good as mine for why an enum can’t be used as a map key. I filed an issue requesting this and it was denied with an explanation: https://gi
by sgammon 1y ago
> Your guess is as good as mine for why an enum can’t be used as a map key.
I filed an issue requesting this and it was denied with an explanation:
https://github.com/protocolbuffers/protobuf/issues/7791#issuecomment-940507054 https://github.com/protocolbuffers/protobuf/issues/7791#issu...
- sgammon 1y ago> It’s impossible to differentiate a field that was missing in a protobuffer from one that was assigned to the default value. This is purportedly fixed in proto3 and latest SDK copies (IIRC)
- sgammon 1y ago> Contrast this behavior against message types. While scalar fields are dumb, the behavior for message fields is outright insane. The reason messages are initialized is that you can easily set a deep property path: ``` message SomeY { string example = 1; } message SomeX { SomeY y = 1; } ``` later, in java: ``` SomeX some = SomeX.newBuilder(); some.getY().setExample("hello"); // does not produce npe ``` in kotlin this syntax makes even more sense: ``` some { y.example = "hello". // does not produce npe } ```