Ok, I'm taking the JavaFX with Passion course and have an issue that I can't seem to figure out.
It's similar to this question -
http://stackoverflow.com/questions/657486/why-doesnt-this-binding-code-work-as-expected-in-javafx
def numbers = [1..10];
var currentNumber = 0;
for (currentNumber in numbers){
var evenOrOdd = bind if (numbers[currentNumber] mod 2 == 0)
"----{numbers[currentNumber]} is an even number"
else "----{numbers[currentNumber]} is an odd number";
println("{evenOrOdd}");
}
and my output -
----2 is an even number
----3 is an odd number
----4 is an even number
----5 is an odd number
----6 is an even number
----7 is an odd number
----8 is an even number
----9 is an odd number
----10 is an even number
----0 is an even number
The issue I'm having is that it 'looks' to run right except it doesn't display 1 as an odd number and then it adds a 0 after the 10. I spent some time stepping through the program and can't seem to find out how/why it's doing this.
I can get it to run great without any binding so not sure if that's what's causing my problem.
Any ideas/thoughts?
~Allen