> Date: Wed, 30 Jun 2021 13:27:21 +1000
> From: Reuben ua Bríġ <u5644...@anu.edu.au>

> it seems a lot of people are having difficulty with my ?: expression.
> 
> rather than going through each branch yourself, think of it like a
> `boolean' switch that stops on the first `true' question (the bit on
> each line before the ?), and then chooses the corresponding `answer'
> (the bit before the :).  try it on this one:
> 
>       /* read the above paragraph BEFORE the following code! */
>       max(a,b,c) {
>       return
>               a > b && a > c ? a :
>               b > c ? b :
>               c;
>       }

got the hang of that? you may be ready for a more efficient version:

/* read the quoted code BEFORE the following code... */
max(a,b,c) {
return
        a > b ? (
                a > c ? a :
                c
        ) :
        b > c ? b :
        c;
}

Reply via email to