How does proto3 handle default values and field presence, and what does the 'optional' keyword do?
Last updated
Proto3 scalars default to zero values (0, empty string, false, first enum value). Defaults are not sent on the wire, so unset and set-to-default look identical.
optionalrestores explicit presence tracking, generating ahas_field()accessor (implemented like a single-fieldoneof).Message-typed fields already track presence.
repeatedfields do not: an empty list is just empty.