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.
You are correct. names.sort! will modify the original list, which is probably not what is desired by this method.
I think referring to Codewars Test Docs will help.
Finally done it.
I eventually got it to pass by simply doing
raise "random text" if
, followed by the error conditions.Exception is the vague part because the test output just says
Test Failed Exception:Exception Exception:Exception
I was able to get it to pass with a specific Excpetion such as
InputException
. Also seing the solutions now, there are a few different options here but it can't just be raising anException
. Hopefully this is more clear.See my answer to @arieh.
Description is very vague, but basically author is expecting You to raise an exception if:
a) any char in the string is not a number
b) passed string is empty
Like others I have no idea how to get past the error cases. Please advise.
The instructions can/should be more explicit when defining how errors should be handled
It should handle errors for empty strings or strings which don't represent a decimal number
. So far returningfalse
or raising anException
don't appear to get through the error test cases.It should be false as the 7 in the middle is not on the right nor on the left (It should be ignored)
break if (str.empty? || str.to_i == 0)
This seems wrong aswell... :/ I dont know how to handle exeptions
I got the main right but with error hadling the below code is wrong... What am I missing..?
raise ArgumentError, 'String is empty' if str.empty?
raise ArgumentError, 'String is not numeric' if str.to_i == 0
As far as I'm aware, this will also change the array passed into the function, rather than just returning a sorted version.