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.
Nope, I didn't realize
\Z
also caught trailing newlines. Thanks for the heads up! I'll update my solution.EDIT: Turns out this is my old solution. Its already been improved.
One of the requirements is that it must throw NoMethodError if the Hash doesn't include the key. If a default is defined, this solution will return the default anytime the method is missing even if the key doesn't exist.
Still, it passes all the tests and it's succint. Kudos to you!
I'm humbled by this solution and I have learned much from it.
Elegantly written solution.
Good use of Regex. I put the test for length in the block.