That's exactly how we use them: One-liners for short expressions and
stacked for long ones, especially GStrings. Highly context-specific.

Christopher Smith

On Mon, Jul 27, 2026, 12:03 MG <[email protected]> wrote:

> Hi Gianluca,
>
> I might misuderstand what you propose here, but for me the whole idea
> behind cond ? trueBranch : falseBranch is that it is a one-liner.
> Otherwise it is better suited for if-else-...
>
> Having said that, I can see that this way of formatting might make sense,
> if trueBranch and falseBranch are long(ish) String/GString|s (which we in
> our code do not have) - but as a general formatting rule, I would be
> against this.
>
> Cheers,
> mg
>
>
> Am 27.07.2026 um 14:38 schrieb Gianluca Sartori:
>
> Hi people,
>
> I've proposed the following PR to the Grails project in a rush, but I
> guess its proper place is the Groovy project.
>
> https://github.com/apache/grails-core/pull/16055
>
> We usually format ternary operators like this for readability:
>
> String message = condition
>         ? "Value when true"
>         : "Value when false"
>
> Would you accept such PR on the groovy-developer skill?
>
> Cheers,
> Gianluca
>
> Gianluca Sartori
> --
> https://dueuno.com
>
>
>

Reply via email to