4.3 Matching Against Type Patterns
Methods defined on hash tables can bind type parameters to the types of the keys and values of the table:template object
hash_table[Key <= hashable, Value]isa
collection[Value];
method
fetch(t@:hash_table['Key,'Value], key:Key):Value { ... }
Since all hash tables must take hashable keys, when type checking the body of the fetch
method, the type checker can assume that the Key
type variable is a subtype of hashable
.
Generated with Harlequin WebMaker