Field access and function calls

Accessing fields and calling methods in haXe is quite easy. All fields of an object (that is all functions that are variables of this object) are accessed by using the dot notation. So, if you want to access the name variable of an object named user you can do so in the following way:

user.name

Calling a function is really easy too, all you have to do is put parentheses after the function's name and eventually write all of your arguments inside the parentheses, separated by commas. Here's how to call a function named sayHelloTo of an object named user, taking two strings as parameters:

user.sayHelloTo("Mr", "Benjamin");

That's all! It's quite easy, really.

Get haXe 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.