TRUE and FALSE

Chip Salzenberg chip at tct.uucp
Sat Sep 8 00:24:41 AEST 1990


According to joare at sdata.no:
>	return f() || g();

Perl also has the LISP meaning for this operation.

This C equivalent is too verbose:

>	a = f();
>	if (a)
>		return a;
>	else
>		return g();

Try instead:

        return (a = f()) ? a : g();

Note that GNU CC has a ?: operator where the second operand defaults
to the value of the first operand.  So with GNU CC, you can write:

        return f() ?: g();

Followups to alt.lang.cfutures.
-- 
Chip Salzenberg at Teltronics/TCT     <chip at tct.uucp>, <uunet!pdn!tct!chip>



More information about the Comp.lang.c mailing list