[ Team LiB ] Previous Section Next Section



Must a control structure's test expression result in a Boolean value?


Ultimately, yes. However, in the context of a test expression, zero, an undefined variable, or an empty string is converted to false for the purposes of the test. All other values evaluate to true.


Must I always surround a code block in a control statement with brackets?


If the code you want executed as part of a control structure consists of only a single line, you can omit the brackets. The code examples in this book retain brackets to promote readability. Retaining the brackets for single-line control statements can also help guard against bugs as new lines are added to the block over time.


Does this hour cover every kind of loop there is?


No. In Hour 7, you'll encounter the foreach statement, which enables you to loop through every element in an array.

    [ Team LiB ] Previous Section Next Section