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.
@ColbyDauph is correct about the purpose of the Kata. It is intended to make new Rubyists aware of existing features, which means that this solution is "really solving it". However, I'm not a big fan of Kata being used this way and would much rather have problems which challenged the user to create his or her own solution.
As far as I can tell there is no way to prevent a user from submitting a solution that uses #inject. Maybe that means this problem is not suitable for a kata.
Some current solutions return 0 for
[0].accumulate(nil, :+)
,which differs from
[0].inject(nil, :+)
which raises an errorNoMethodError: undefined method '+' for nil:NilClass
I'd suggest adding a test case similar to
Please do explain what
s
is and where it comes from.OK, that is acceptable. Thanks for explaining.
Just so you know where my point of view comes from, here are some practical cases where the ability to use both
attr_lazy :even
andattr_lazy :even?
to memoize results would be useful.According to the test cases, you expect that when
@even
is set then invokations of#even?
respect this as part of the memoization. This seems inconsistent to me because in Rubyeven
andeven?
are two distinct identifiers. Take for example a class that has bothattr_lazy :even
andattr_lazy :even?
. In this case the test case seem to apply to two different lazy attributes.