`ArrayBuffer.result` just return itself, so this line should be

```scala
ab.toArray
```