Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 463 Bytes

File metadata and controls

23 lines (16 loc) · 463 Bytes

Instantiation

When you make an instance of a class that takes generic parameters you are expected to provide the actual concrete types you want to be used in place of any type variables.

You do this by writing the name of the types inside a <> alongside the call to new.

class Box<T> {
    T data;
}

void main() {
    var boxOfString = new Box<String>();

    boxOfString.data = "abc";

    String s = boxOfString.data;

    IO.println(s);
}