Prev | Current Page 223 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

When you want to enforce that a certain
parameter can assume a null value, it is a better choice to make it optional. Flash 9 has a slightly
different behavior regarding null values. Refer to Chapter 12 for further instructions.
107
Chapter 5: Delving Into Object-Oriented Programming
Optional parameters are independent: When more than one of them is declared in a row, it is possible to
set a value for the last parameter without providing a value for the previous ones, although it can be a
confusing practice. As an example consider this function:
function foo(?a : String, ?b : Int, ?c : Person)
{
// body goes here
}
All of the following statements are correct and correctly assigned to the right argument; arguments that
are not explicitly stated are set to null .
foo(1);
foo(???John???);
foo(???John???, 1, person); // where person is an instance of Person
foo(person);
But the following does not compile:
foo(person, ???John???); // wrong sequence
Variables
The formal definition of a class instance variable is described in Figure 5 - 3 .


Pages:
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235