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.
did you find out?
Yeah, in ruby
nil
andfalse
equate to false, and everything else (including 0!) are truthy. The zero thing causes some fun bugs for beginners :)It's a two-dimensional array, and both example test cases support this. Here are the arrays used:
The first is a 2x2 array. The second is an empty array, it doesn't have any subsets. Both tests work.
A
;
in Ruby is the equivalent to a line break. The author uses it so that the block returnsh
instead of whateverh[w] += 1
would return. What the.inject
and its block does in this solution is usually written like this in Ruby:each_with_object(Hash.new(0)) { |w, hsh| hsh[w] += 1 }
This is a tiny bit more readable, but does on the other hand take 8 characters more to type.
Ruby is the irritating wildcard in languages when it comes to this kata. Your function will be passed a proc/lambda in Ruby, so sorry if my wording confused you.
It simply ensures that I know the return value in the case of failure.