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;
        }

remember that, whether or not you understand the C grammar, the two
blocks of code i provided last email are equivalent.  i find the ?:
notation rewarding in its simplicity and compactness.  it is no more
complicated then elif, but more regular and needs fewer ().

finally i note that K (from K&R), rather than write in idiomatic
fortran, wrote ratfor.  no, i am not comparing myself to, K neither my
example to ratfor: i have not changed C, merely understood its grammar.
(thanks R!)

thanks for your time,
reuben.

---
> ANSI 'K'&'R' is really just 'B' in disguise.

at least one person missed the ''

Reply via email to