Ad
  • Custom User Avatar

    You are correct. names.sort! will modify the original list, which is probably not what is desired by this method.

  • Custom User Avatar

    I think referring to Codewars Test Docs will help.

  • Custom User Avatar

    Finally done it.

  • Custom User Avatar

    I eventually got it to pass by simply doing raise "random text" if, followed by the error conditions.

  • Custom User Avatar

    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 an Exception. Hopefully this is more clear.

  • Custom User Avatar

    See my answer to @arieh.

  • Custom User Avatar

    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

  • Custom User Avatar

    Like others I have no idea how to get past the error cases. Please advise.

  • Custom User Avatar

    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 returning false or raising an Exception don't appear to get through the error test cases.

  • Custom User Avatar

    It should be false as the 7 in the middle is not on the right nor on the left (It should be ignored)

  • Custom User Avatar

    break if (str.empty? || str.to_i == 0)

    This seems wrong aswell... :/ I dont know how to handle exeptions

  • Custom User Avatar

    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

  • Custom User Avatar

    As far as I'm aware, this will also change the array passed into the function, rather than just returning a sorted version.