- var
- closures (blocks, lambdas)
- enhancements (I think this is like extension methods)
- object initializers
var square = \ x : Number-> x * x var indsquare = \ x: Number, y: Number -> print(java.lang.String.format("%3d %7.2f", {y.intValue(), square(x)})) var values = { 1, 2, 3, 5, 7, 11, 13, 17, 19, 23 } values.eachWithIndex(\val, index -> indsquare(val, index+1))
So, square and indsquare are blocks.
And we get this result:
1 1.00 2 4.00 3 9.00 4 25.00 5 49.00 6 121.00 7 169.00 8 289.00 9 361.00 10 529.00
What is the type of values? java.util.ArrayList!
And we were able to call eachWithIndex on it and pass another block as a parameter.
Update: 11/12/2010
As Carson noted in the comments, there are instructions in the gosu-lang discussion forums that show how to make it work with Helios. I've tried it and it seems to work.
Apparently it works w/ Helios, but it is not supported:
ReplyDeletehttp://groups.google.com/group/gosu-lang/browse_thread/thread/cba03e754b62894b
Cheers,
Carson
Thanks, Carson. I just came across that post on the gosu-lang group and it worked for me as well!
ReplyDelete