1 <!DOCTYPE HTML PUBLIC
"-//W3O//DTD W3 HTML 2.0//EN">
2 <!-- This collection of hypertext pages is Copyright 1995, 1996 by Steve Summit. -->
3 <!-- This material may be freely redistributed and used -->
4 <!-- but may not be republished or sold without permission. -->
7 <link rev=
"owner" href=
"mailto:scs@eskimo.com">
8 <link rev=
"made" href=
"mailto:scs@eskimo.com">
9 <title>section
3.2: If-Else
</title>
10 <link href=
"sx6a.html" rev=precedes
>
11 <link href=
"sx6c.html" rel=precedes
>
12 <link href=
"sx6.html" rev=subdocument
>
15 <H2>section
3.2: If-Else
</H2>
17 <p>The syntax description here may seem to suggest
18 that
<I>statement
</I><tt><sub
></tt>1<tt></sub
></tt> and
<I>statement
</I><tt><sub
></tt>2<tt></sub
></tt>
19 must be single, simple statements,
23 a block of statements enclosed in braces
<TT>{}
</TT>
24 is equivalent to a single statement.
26 </p><p>``Coding shortcuts''
29 </pre>can indeed be cryptic,
30 but they're also quite common,
31 so you'll need to be able to recognize them
32 even if you don't choose to write them in your own code.
33 Whenever you see code like
37 </pre>where
<TT>x
</TT> or
<TT>f()
</TT>
38 do not have obvious ``Boolean'' names,
41 </p><p>Don't worry too much if the multiple
<TT>if
</TT>/
<TT>else
</TT> ambiguity
43 doesn't make perfect sense;
44 just note the deep sentence:
45 <blockquote>...it's a good idea to use braces when there are nested
<TT>if
</TT>s.
49 <a href=
"sx6a.html" rev=precedes
>prev
</a>
50 <a href=
"sx6c.html" rel=precedes
>next
</a>
51 <a href=
"sx6.html" rev=subdocument
>up
</a>
52 <a href=
"top.html">top
</a>
55 This page by
<a href=
"http://www.eskimo.com/~scs/">Steve Summit
</a>
56 //
<a href=
"copyright.html">Copyright
</a> 1995,
1996
57 //
<a href=
"mailto:scs@eskimo.com">mail feedback
</a>