Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

JavaWorld Daily Brew

Bidirectional binding

 

In addition to corrections to local variable binding the next update of the JavaFX interpreter will include extended bidirectional binding, including of logical negation, unary minus, arithmetic, and sequence indexing. Here's a JavaFXPad example you can try out:


// logical negation
var a = true;
var b = bind not a;
assert b == false;
b = true;
assert a == false; // passes

// arithmetic
var x = 10;
var y = bind -x + 100;
assert y == 90;
y = 40;
assert x == 60; // passes

// sequence elements
var seq = [1, 2, 3];
var elem1 = bind seq[1];
elem1 = 500;
assert seq == [1, 500, 3]; // passes
delete seq[1];
assert elem1 == 3; // passes
insert 0 as first into seq;
assert elem1 == 1; // passes
var value = bind elem1;
value = 999;
assert seq == [0, 999, 3]; // passes