Has#
The has(x.f) macro tests whether field f is present on a message x.
Conditional access#
Combine has with the conditional operator for safe field access.
This is particularly useful for wrapper types, which evaluate to null when unset.
// input: user = example.v1.User{name: "Alice"}
has(user.nickname) ? user.nickname : user.name
// result: "Alice" (string)
See also#
- Protocol Buffers - Protobuf messages
- Well-known types - Wrapper field semantics