Generics Our own test helpers (AssertEqual , AssertNotEqual ) Assert on integers Assert on strings Recap on type-safety A function that takes a string or an integer? (or indeed,...
Generics Type variables inference Generic structs and modules Generic types inheritance Generics Generics allow you to parameterize a type based on other type. Consider a Box...
Hello World of Generics Working with Generic Type Variables Generic Types Generic Classes Generic Constraints Using Type Parameters in Generic Constraints Using Class Types i...
Templates / Generics Generic Functions Generic structs Where clause Templates / Generics C++ offers templates as a way to write generic code using an abstract type and then ...
Implicit generics Implicit generics A type class can be used directly as the parameter’s type. # create a type class that will match all tuple and object types type Record...
Intro to Generics Introduction Problem Access Elements Loop and Print Introducing Generics Generic Loop Non-Generic Struct Non-Generic Instance Generic Struct Define Type E...
Implicit generics Implicit generics A type class can be used directly as the parameter’s type. # create a type class that will match all tuple and object types type RecordT...
An iso specific class A capability generic class In the examples presented previously we’ve explicitly set the reference capability to val : class Foo [ A : Any val ] ...
Why use generics? Why use generics? Generics are often required for type safety, but they have more benefitsthan just allowing your code to run: Properly specifying generic t...