Normally, I would build out classes for this sort of thing. A Checkbook class with Entries that can be Debit or Credit and so on so that it's easier to write and maintain tests in TDD style. This implementation is just a simplistic top-down functional approach. It's still testable, but it wasn't as easy to compose as an OOP solution would be.
Ruby Language
Normally, I would build out classes for this sort of thing. A Checkbook class with Entries that can be Debit or Credit and so on so that it's easier to write and maintain tests in TDD style. This implementation is just a simplistic top-down functional approach. It's still testable, but it wasn't as easy to compose as an OOP solution would be.
script with specs
output