Category "ternary-operator"

Ternary operator implicit cast to base class

Consider this piece of code: struct Base { int x; }; struct Bar : Base { int y; }; struct Foo : Base { int z; }; Bar* bar = new Bar; Foo* foo =

What is the idiomatic Go equivalent of C's ternary operator?

In C/C++ (and many languages of that family), a common idiom to declare and initialize a variable depending on a condition uses the ternary conditional operator