Traits
Movable: trait {
move: fun(self, dx: float, dy: foat)
}Vector: struct {
x: float
y: float
}
implement Vector: Movable {
move: fun(self, dx: float, dy: float) {
self x += dx
self y += dy
}
}point := new Vector {
x: 100
y: 100
}
point move(10, 5)Last updated