Line Commenting
Line commenting is useful if you want to describe what a particular line of code is doing, or you want to
provide a brief instruction between lines of code. You start a line comment using two successive forward
slash symbols ( // ):
// This is a line comment
var someVariable : Float; // This is also a line comment
Anything following a forward slash pair is ignored by the compiler until the next new line, where code
can continue uninterrupted. Even other comment symbols are ignored, so following a line comment with
a multiline block comment on the same line will likely cause a compiler error:
var someVar = 0; // line comment /* new block comment
this line will cause an error
*/
Part I: The Core Language
38
Converting Data Through Casting
So far, you ??™ ve done quite a bit dealing with types and their restrictions, and can now see how typed
values are kept separate from other types by the compiler. However, a lot of the data you will deal with
will require some form of conversion so that, for example, a class of type car can fit into a variable of
type Vehicle .
Pages:
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109