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.
#clamp
– niiiice!Since ruby 2.4 it's built-in, see my fork
Interesting method/name:
#clamp
.Javascript exhibits this also. Since arrays are pass-by-reference, and the tests use the array after calling the user's function with it, they require the user's solution to leave the items array unmodified.
It's best practice to not modify arguments anyway (falls under the category of undeclared side effects), but it would be helpful if the tests were more specific in how they failed to tell you you've done a no-no instead of just sounding broken with "got: correct result, expected: wrong result" and leave you sitting there scratching your head trying to figure out why it failed.
A perfect example of when not to use point-free style.
This catches every missing method. Very bad practice.
Ruby.
What language are you using?
Well I just wasted about an hour on this because my method sorted the items array in-place, causing my solution to not match because the expected output was getting a different input.
Is it possible for you to pass a dup of an array to avoid this problem?