Skip to main content

"... JavaFX has First-class functions.."

1 reply [Last post]
ramon_lopes
Offline
Joined: 2007-04-20
Points: 0

Hi folks,

I would like to know how to create new function at runtime, because I've read about JavaFx has Firs-class function.
Can someone give any example?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ramon_lopes
Offline
Joined: 2007-04-20
Points: 0

Hi Folks,

I think that I found the answer:

http://en.wikipedia.org/wiki/First-class_function

So I created this simple example:
/*
* Main.fx
*
* Created on 15/12/2007, 15:53:38
* Ramon Lopes
*/

var z2 = function(x: Number, y: Number){
return x / y;
};

function z3(a:Number,b:Number,f:function(c,d):Number){
var k = f(a,b);
return(k);
}

println(z3(4,2,z2)); //yield 2.0

Regards