1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 fun iterator
: MyIterator do return new MyIterator
20 super Iterator[String]
23 redef fun is_ok
do return count
< 3
24 redef fun next
do count
+= 1
25 redef fun item
do return "Item{count}"
29 fun iterator
: MyMapIterator do return new MyMapIterator
33 super MapIterator[String, String]
36 redef fun is_ok
do return count
< 3
37 redef fun next
do count
+= 1
38 redef fun item
do return "Item{count}"
39 redef fun key
do return "Key{count}"
43 var col
= new ColIterable
44 for v
in col
do print v
47 var map
= new MapIterable
48 for k
, v
in map
do print
"{k}:{v}"