Friday, June 19, 2009

JavaFX Datatypes

String

var s1 = 'Hello';
var s2 = "Hello";

embed expression

def name = 'Joe';
var s = "Hello {name}"; // s = 'Hello Joe'

expression within expression

def answer = true;
var s = "The answer is {if (answer) "Yes" else "No"}"; // s = 'The answer is Yes'

join and concatenate

def one = "This example ";
def two = "joins two strings.";
def three = "{one}{two}"; // join string one and string two
println(three); // 'This example joins two strings.'

Number and Integer

def numOne = 1.0; // compiler will infer Number
def numTwo = 1; // compiler will infer Integer

explicit variable declaration

def numOne : Number = 1.0;
def numTwo : Integer = 1;

Boolean

var isAsleep = true;

Duration (The Duration type represents a fixed unit of time (millisecond, second, minute, or hour.))

5ms; // 5 milliseconds
10s; // 10 seconds
30m; // 30 minutes
1h; // 1 hour

Void and Null

function printMe() : Void {
println("I don't return anything!");
}

function checkArg(arg1: Address) {
if(arg1 == null) {
println("I received a null argument.");
} else {
println("The argument has a value.");
}
}

More of this here

No comments: