Prev | Current Page 191 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

All class functions take the following structure:
[public/private] [static] function < name > ( param1 : paramType [, param2 :
paramType], ...] ) : returnType
{
...
}
The public, private, and static identifiers are discussed in the next chapter, so you ??™ ll skip those for now.
Next is the function keyword, which states that what follows is the declaration of a function. The name
of the function comes next and is restricted by the same rules as haXe variables, which states that it can
consist of underscores ( _ ), letters, and numbers, but must not start with a number and must not be the
same as a haXe keyword. Under the general haXe naming conventions, function names always start with
a lowercase letter, though this is at your discretion.
86
Part I: The Core Language
Following the function name are the parameter declarations, which are surrounded by round brackets.
These parameters are declared similarly to local variables without the var keyword and follow the same
type inference rules. You can have as many parameters in a function as you like, though less is best if at
all possible, for ease of use.


Pages:
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203