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.
This solution and others like it has helped me a lot with refactoring
thx for your advise :)
an alternative is to use
.positive?
instead of>= 0
, more characters indeed but also more idiomatic.Nice one!
Took some time to solve for sure.
For everyone who's still struggling: do not forget about umbrellas you leave at work or home.
Great kata! Really enjoyed it.
And for everyone, who is having troubles with huge string, you really should dig in the manual: https://ruby-doc.org/core-2.2.0/Enumerator.html (for example)
BTW the same problem may occur in
assert_not_equals(actual, expected...)
It's an error in a framework which leads to another error. You should consider to leave a comment here: http://www.codewars.com/docs/ruby-test-reference
Solution is simple and won't affect Katas that work fine right now.
Oh well, my bad, sorry. Didn't think Codewars is using a custom test framework.
According to https://github.com/Codewars/kata-test-framework-ruby/blob/master/framework.rb#L147 real order is
actual, expected
, so you're right.Now I'm curious why is it implemented this way.
Just checked the order of arguments passed in in the Codewars Ruby test fixture;
actual, expected
is the correct order (in Codewars).Thanks for the info khovansky-al - I am no expert in Ruby (both inside and outside of Codewars) so I wasn't very sure of the order of arguments passed in.
I will make sure I pass in the values in the correct order next time I author a Ruby kata :)
EDIT: Wait khovansky-al, are you sure the test fixture you are referring to in the article is the test fixture used in Codewars?
According to rubydocs, it is not. http://ruby-doc.org/stdlib-2.1.0/libdoc/test/unit/rdoc/Test/Unit/Assertions.html#method-i-assert_equal
Correct order is
expected, actual
.In Java (and possibly a few other languages) the correct order is
expected, actual
but in Ruby I think the correct order isactual, expected
.Okay, it's a pity that you can no longer modify your test case. Anyway it's a bad practice to use assert_equal( expected, actual ) reversed. I guess we understand each other, right? And by the way is it possible to have a look at "defaults" about Kata's input and etc? I'm quite new to this site, it might be helpful in solving other Katas.
As a side note, if over 500 people have completed a Kata (as in this case), the author of the Kata can no longer modify the test cases so raising an issue regarding the test cases is useless at this stage.
That is the user's fault, not the author's. By default, if the Kata does not ask the user to modify the original input passed in, the user is expected to leave the original input intact.
Loading more items...