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.
In the Ruby version, there doesn't seem to be a test case for any month with only 30 days being tested with a 31st date.
i.e. [04-31] => should fail
There's at least one accepted solution that fails to cover this case (example in my View Solution)
Any month with 30 days but that was attempted w/ a 31st date would pass in this.
i.e. [09-31] => valid date
Honestly kind of surprised that this test case was missed, especially in the extended cases...
I'll give you a quick explanation here, look it up to get further information (StackOverflow, ruby docs, etc.)
Anyways, say you have an object
foo
and a method associated with that objectbar
. You are probably accustomed to sayingfoo.bar(arg1, arg2)
to call thebar
method with some parameters.With
send
, you can call any method on an object by passing it in throughsend
.I.e.
foo.send(:bar, arg1, arg2)
bar
method as parametersIn this context,
send
allows us to dynamically call a method of a variable name on an object of a variable name. Without it, we would probably end up having to define individual methods for each number.So for example
n
is an instance/object of the Integer class. That means it has methods we can call on it. Saying1 + 2
is actually the same as saying1.+(2)
To tie into the operands, when we say
n.send(*args)
,args
will actually initially represent the array returned by the similar dynamic method creation we are doing with the operands.*args
) specifies an argument list of variable length, and treats each index of the array as an individual parameterSo by doing so, we finally have something like this:
->
six(times(two()))
->
six(times(2))
->
six([*, 2])
->
6.send(*, 2)
->
6.*(2)
=>
12
I got a bit carried away but I hope that helps explain things for you!