Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
We were asked to write a function which takes a non-negative integer that means it would be provided as positive or zero. The rule is simple: Do not expand the scope if no one asks about it.
Hey Farid,
Thanks for your comment. I actually didn't forget the validation but intentionally left it out. As you correctly quoted the description, the goal was to write a function that "takes a non-negative integer." This implies that the argument cannot be negative. You may also have noticed that my implementation doesn't handle values greater than 359999, and it's for the same reason. The assignment says, "The maximum time never exceeds 359999." The author of this kata also didn't specify expected behavior for those cases, nor did they provide tests.
Having said all that, I agree that this code isn't production ready without the validation. But if it were up to me, I'd ensure that no invalid values can be passed (e.g., via static analysis or a dedicated value object) to eliminate the need for validation in this function altogether.