Ternary Expressions with Go Generics
A ternary expression is a common logical construct available in many programming languages. It shortens an if/else condition into a single statement: someCondition ? "yes" : "no" In the above example, ? means “then” and : means “else”, so the example reads if someCondition is true, then use "yes", otherwise use "false". When the Go 2 proposals were being considered, there were a number of proposals for the addition of ternary expressions into the language proposed by the community: