Learning Haxe: Part 2: Creating and Using Variables

Learning Haxe

Haxe is a strongly-typed multi-paradigm programming language that also supports cross-platform compiling into many different source and byte-code languages such as ActionScript 3, JavaScript, Java, C++, C#, PHP, Python, Lua, and Node.js.

Creating Variables

When creating variables, the keyword var is used. This identifies some name as a variable along with its type.

var name:Type;

Haxe is a strongly-typed programming language. This means that all variables have a type. When creating variables, it must have a type to identify its contents.

The type of the variable follows its name with a colon. Every variable must have a type and colon. This statement ends in a semicolon.

Basic Types

There are three basic types in Haxe: Int, Float, and Bool.


An Integer in Haxe is any whole number.


A floating-point number is a decimal number.


A Bool is a Boolean value, either “true” or “false.”

Using Variables

Haxe supports many operators for working with two or more Int and Float values.

  • Addition: (+)
  • Subtraction: (-)
  • Multiplication: (*)
  • Division: (/)
  • Modulo: (%)

Two unary operators are also supported:

  • Increment: (++)
  • Decrement: (–)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.