## Seven Languages in Seven Weeks: Day 5

Have you ever wanted some bastard to redefine division on you? I haven't either, but if it ever comes up, you can totally do it in Io:

```
Number trueDiv := Number getSlot("/")
Number / = method(n,
if(n == 0,
return 0,
return self trueDiv(n)
)
)
```

... and here's something that approaches useful: A two-dimensional matrix class that's backed by a one-dimentional list. It includes getter, setter and iterator methods. Yay!

```
Matrix := Object
Matrix dim := method(x, y,
self width := x
self height := y
self buffer := list()
self buffer setSize(x * y)
)
Matrix checkBounds := method (x, y,
if(x >= width or y >= height,
Exception raise("index out of bounds")
)
)
Matrix get := method(x, y,
checkBounds(x, y)
return self buffer at(x + y * width)
)
Matrix set := method(x, y, value,
checkBounds(x, y)
self buffer atPut(x + y * width, value)
)
Matrix forEach := method(f,
for(y, 0, height - 1,
for(x, 0, width - 1,
f call(x, y, self get(x, y))
)
)
)
```