Ad
  • Custom User Avatar

    You should never put any information which might give away the kata solution in the comments (without checking the "mark as having spoiler content" box) as they're visible to every one.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Range has a #sum method, which will cover the 0 case on its own: (1..num).sum works perfectly

  • Default User Avatar

    Removing every theoretical edge case isn't relevant and is not best pracitice and can even fall into bad practice. Staying pithy and readable is best practice. Much depends on the context whether you would use this or something else. If it's going to be used generally in a large application best to use a well worn solution or spend more than the 2 minutes creating method but you need to know the context of the method.

  • Custom User Avatar

    edge case fail (as pointed out, with an example fix) and bad runtime makes me seriously question the people calling it best practise. I would not like this in production code.

  • Custom User Avatar

    fix by doing .reduce(0, :+)

  • Custom User Avatar

    I'm getting this failure message,

    Must allow to set code 'abnyyvuciwhtdi': no id given

    Dispite all my test cases passing. What does that 'no id given' message mean?

    My test cases ( that are all green )

    Test.expect_error { Code.a }
    Test.expect_no_error { Code.a = 10 }
    Test.expect( Code.a == 10 )

    Test.expect_error { Code.valghpf }
    Test.expect_no_error { Code.valghpf = 22 }
    Test.expect( Code.valghpf == 22 )

    Test.expect_error { Code.nil }
    Test.expect_no_error { Code.nil = 22 }
    Test.expect( Code.nil == 22 )

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution