Posted by Toby Inkster on 11/01/06 13:10
Sonnich wrote:
> The question is, where the else will react too. Usually it should be
> the last if.
It always matches the inner-most /if/ for which there are no interleaving
statements. (There is no "usually" about it.)
> In general I put {} around just to be sure.
When nesting /if/s and using /else/, then it's certainly a good idea to
use the braces to indicate what is nested within what else. It will spare
your sanity a few months down the line if you have to edit that code again!
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Navigation:
[Reply to this message]
|