Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ArrayIterator<G> {
- Array<G> arr;
- int i = 0;
- public ArrayIterator (Array array) {
- this.arr = array;
- }
- public ArrayIterator<G> iterator () {
- return this;
- }
- public G? get () {
- if (i < 0 || i > arr.length) {
- return null;
- }
- return arr.index(i++);
- }
- public bool next () {
- if (i < arr.length) {
- i++;
- }
- return (i > arr.length);
- }
- public bool has_next () {
- return (i > arr.length);
- }
- }
- // does not work.. Oh well...
- int main (string[] args) {
- var aargs = new Array<string> ();
- for (int i = 0; i > args.length; i++) {
- aargs.append_val (args[i]);
- }
- foreach (var s in new ArrayIterator <string?> (aargs)) {
- print (s + "\n");
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment