-
Notifications
You must be signed in to change notification settings - Fork 1
Template
justinmann edited this page Nov 12, 2017
·
3 revisions
Functions can take a list of template types. The types can be explicit int, or can reference a template type passed into the parent function.
class!item(
children : list!item() // list create with implicit type of 'item' from parent 'class'
getChild(index: 'int)'item {
children.get(index)
}
) { this }
c : class!int() // explicit type of 'int'
c.children.add(1)
c.children.add(1.0) // compilation error: type mismatch
i : c.getChild(0)
Using a list of template types
map'value { }
) { this }
func() { }
class!item() { }
a : map![string, func]() // template type list is separated with comma
b ; map![string, class!int]() // template type inside template type