Prev | Current Page 235 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"


114
Part I: The Core Language
The objectInstance is a reference to an object, which implements the class that defines the
runtime property.
Static Fields
Static fields are characteristics that pertain to the class itself and not to its instances. A value set in a static
variable will be the same whichever the context it is used in is and as long as the execution doesn ??™ t come
to an end. They are conventionally used to store global values or to perform actions that rely only on the
passed parameters. In a certain measure they replace the needs for global functions as encountered in
procedural programming, with the plus of having a very clear context determined by the container class.
When a static field is referenced from inside the declaring class, it is possible to simply use its name
unless it conflicts with other identifiers; in that case, and always when the field is used outside its
declaring class, it is needed to prefix it with the class name, as in the following example.
class Main
{
static function main()
{
Sample.


Pages:
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247