Parameterized classes can be defined in Bobbee:
class Circle <T> {
# A circular list of items of type T.
var values : ArrayList<T>;
var index : integer = 0;
def this (this.values);
def add (newValues : T ...) : void :> values ++= newValues;
def [index : integer] : T :>
if length values == 0 then null
else values [index % length values];
def next () : T :>
if length values == 0 then null
else values [(index +.= 1) % length values];
}
| Beyond OmniMark | Sam Wilmott |
| Slide 26 of 37 | www.wilmott.ca |