Type parameters correspond to the Java generics.
A type can be parameterized like so:
type List[T] { ... }
When creating a new implementation of this list that can only contain elements of type Number (lets say that it's optimized for that), we use:
class IntegerList : List[Number] { ... }
Of course one can subtype with type parameters:
type Whatever[T] : Supertype[String] { }
This defines a Whatever type that can be parameterized, itself subtyping the Supertype[String] type.
Whatever
Supertype[String]
It is also possible to have type parameters on methods. The are expressed like so:
apply[T, U](val: T): U;
There was an error while loading. Please reload this page.