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.
only if the possible points can be a float or the boundary is changed to be inclusive
Don't you need to make the average a float?
Check that the number isn't negative and, what if it is? Throw an error? There's nothing wrong with throwing an error. In fact, the only real problem is that
spam(-1)
returns""
instead of throwing the error. But since behavior for negative numbers is undefined, it's not a big problem.Yep.
But it's up to the kata solver to decide if they want to handle inputs not accounted for in the test fixture. Everyone has a different goal here, but I've found that people tend to write only what is needed to pass the tests.
If we took every possible scenario into consideration on every kata, this place would be unnecessarily verbose.
The problem here is that whenever a negative number is passed as argument, the method will throw an exception. Wouldn't it be better to check if the number isn't negative?