I just want to share with you with some basic techniques which made 'nice/strange' feeling in my mind ; ) I couldn't run JavaFX brush for SyntaxHighlighter plugin, so some colors dont fit well to code - sorry for that.
Tired of 'plusing' or appending strings? Join them using binding:
def thirdVar = "{one}{two}";You can even use 'if' statements in line to build string:
var s = "The answer is {if (answer) "Yes" else "No"}";Use dynamic types if you admire flexibility...
def numOne = 1.0; def numTwo = 1;...change it to static if you are big fan of clear-intention-code:
def numOne : Number = 1.0; def numTwo : Integer = 1;
Somehow each introduction of new language contains some mind-twisters about collections/arrays. JavaFX is not an exception, but authors named this structure as 'sequence':
def nums = [1,2,3,4,5]; //sequence with numbers only greater than 2 def numsGreaterThanTwo = nums[n | n > 2]; ... //reverse values in sequence var nums = [1..5]; nums = reverse nums; // returns [5, 4, 3, 2, 1]
Lets take sequence which contains strings. Do you want to insert new string in specific place? Not a big deal, really. Sql-developers would love that:
def weekDays = ["Mon","Tue","Wed","Thu","Fri"]; insert "Thu" before days[2]; ... delete "Sun" from days;
Nice feature is defining sequences with range syntax, but its not the end - you can easily set interval for this range:
var num = [0..5]; var nums = [1..10 step 2]; println(nums);//output: [ 1, 3, 5, 7, 9 ]
Coding in JavaFX seems easy to learn - its the most important when you need to kick start your project in new technology.
I have some GUI tutorials after me, but too less to consider JavaFX as concurent to any technology made for client-apps. Im going to look further into it, so stay tuned ;)
Brak komentarzy:
Prześlij komentarz