We just released JS++ 0.5.1, which features the foreach
keyword.
Basic usage is as follows:
external console; int[] arr = [ 50, 40, 30 ]; foreach (int value in arr) { console.log(value); } // Output: // 50 // 40 // 30
More complex usage, such as arrays of objects, are also possible:
external console; class Foo { string bar() { return "bar"; } } Foo[] foo = [ new Foo(), new Foo(), new Foo() ]; foreach (Foo value in foo) { console.log(value.bar()); } // Output: // "bar" // "bar" // "bar"
Additionally, the for-in
keyword has been implemented. It is a counterpart to the foreach
keyword in the sense that it enumerates keys rather than values.