Skip to content

Instantly share code, notes, and snippets.

@ousado

ousado/Test.hx Secret

Last active Nov 3, 2016
Embed
What would you like to do?
arrow functions
class Test {
static function main(){
var a = () -> 123;
var b = a -> 123 * a;
var b1 = (a) -> 123 * a;
var b2 = (a:Int) -> 123 * a;
var ff = a -> b -> b*a;
var c = a -> [for (i in 0...a) i*a];
var d = (a,b:Int) -> 123 + a + b;
var e = (a:Int,b) -> 123 * a + b;
var f = (?a:Int) -> trace('a: $a');
var f2 = (a:Int=3, b=2) -> trace('a: $a b: $b');
var f3 = (a = 3) -> trace('a: $a');
var f4 = (?a = 3) -> trace('a: $a');
trace([
a(),
b(123),
//c(123),
d(123,456),
e(123,456)
].concat(c(15)));
trace(ff(123)(456));
f();
f(1);
f2();
f2(0,0);
f3();
f3(0);
f4();
f4(0);
}
}
/*
Test.hx:31: [123,15129,702,15585,0,15,30,45,60,75,90,105,120,135,150,165,180,195,210]
Test.hx:39: 56088
Test.hx:23: a: null
Test.hx:23: a: 1
Test.hx:25: a: 3 b: 2
Test.hx:25: a: 0 b: 0
Test.hx:27: a: 3
Test.hx:27: a: 0
Test.hx:29: a: 3
Test.hx:29: a: 0
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment