You can indicate that a value is not required.
Just append ? to the type.
/// If provided, it must be an int; otherwise it can be omitted
setting: int?
? Can Appear๐While we say โappend ? to the typeโ, strictly speaking you can place ? after a type name or after an array type.
/// Either int? or [int]
/// Equivalent to writing int? | [int]?
setting: int? |
/// This is an array of int?
/// In JSON, values like [null, 100] are allowed.
/// In languages without null like TOML, only an empty array can represent absence.
setting:
/// This form is not allowed!
setting: int |?