Enhancements In GScript

You may wonder how we get all those great closure-based methods like findAll() and sortBy() onto classes (or interfaces!) in GScript. The secret is a language construct called Enhancements. Here is a stripped down version that puts the findAll() method onto java.util.List:
uses java.util.*

enhancement MySampleEnhancement : List {

[...]

GScript > Java (pt. 3)

Here is how you sum up an array of integers in java:
int[] values = …
int sum = 0;
for( value : values ) {
sum += value;
}
Here is how you do it in gscript:
var values = …
int sum = values.sum()
As a [...]