3 ms·
> Contrast this behavior against message types. While scalar fields are dumb, the behavior for message fields is outright insane. The reason messages are initi
by 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
}
```