Generics. Part 3
Generic types
In addition to generic functions you can declare your own generic types in Jazz.These are custom structures that can work with any type, in a similar way to Array
and Map
.
This sections shows you how to write a generic type Point
. Point
usually means two values x
and y
.You can use this type in math calculation.
Here’s how to write a nongeneric version of a point in this case for a point of int
values:
Note how the generic version of Point
is essentially the same as the nongeneric version, but with a type parameter called T
instead of an actual type of int
. This type parameter is written within a pair of angle brackets (<T>
) immediately after the structure’s name.
Last updated
Was this helpful?