doc/manual: put back the manual in the main repository
[nit.git] / doc / manual / virtual_type.md
1 # Virtual Types
2
3 `type` declares a virtual types in a class. A bound type is
4 mandatory. Virtual types can then be used as regular types in the class
5 and its subclasses. Subclasses can also redefine it with a more specific
6 bound type. One can see a virtual type as an internal formal generic
7 parameter or as a redefinable *typedef*.
8
9 ~~~
10 class Foo
11     type E: Object
12     var derp: E
13 end
14 class Bar
15     super Foo
16     redef type E: Int
17 end
18 var b = new Bar(5)
19 print b.derp + 1 # outputs 6
20 ~~~