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.
There should be a test that requires results to be not in alphabetical order to cut down on all the solutions using
#sort
for no reason.The idea is good, but I think you should specify that all elements in the returned Array have to be Strings.
Also the message you get on a failed test doesn't say why it failed, so I had to resort to some metaprogramming to see what exactly you're testing.
Might be worth specifying how the method should behave in case there are String keys. Otherwise it's a nice intro to
method_missing
, good job.A method with
*args
is guaranteed to receive an array of the arguments, so[*args]
does literally nothing apart from allocating another array and filling it with the contents of theargs
array.Since
define_method
takes a symbol as argument anyway, there's no need to call#to_s
.It's also useless below since
#{}
calls#to_s
on the return value inside.Providing a default argument name would help consolidate the solutions a little bit.
At the moment they mostly differ in what people call the argument, and not the code itself.