Java Reference
In-Depth Information
Sequence operators
JavaFX sequences support several operators:
sizeof—operators return the size when applied to a sequence.
sizeof [1,2,3,4];
Comparison—JavaFX sequences can be tested for deep equality. This means that two
sequences are the same if they are of the same size and contain the same items. The
statement below will print
true
println([1,2,3,4] == [4,3,2,1])
Reverse—this operator automatically reverses the order in which items are referenced in
a sequence.
println(reverse ["Jan", "Feb", "Mar", "Apr");
Sequence operations
JavaFX sequences also support operations to manipulate sequences and sequence
items directly.
Insert-Operation—as the name implies, this operation inserts item(s) into a given sequence.
The following example shows all of the supported form of
insert
.
var months = ["Jan"];
insert
"May"
into
months;
insert
["Mar","Apr"]
before
months[1];
insert
"Feb"
after
months[0];
Besides the
into
directive, note that the insert operation support a
before
and
after
clause which specifies the location (index) where the item is to be inserted.
Union—sequences can be nested using literal declaration to create new lists:
var q1 = ["Jan", "Feb", "Mar"];
var h1 = [q1, ["Apr", "May", "Jun"]];
Delete-Operation—the
delete
operation removes items from a given sequence. The following
example shows the supported forms of delete.
var months = ["Jan", "Feb", "Mar", "Apr", "May"];
delete "May" from months;
delete months[3];