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.
That is an extra fail-safe. In the chance that
strarr.each_cons(k).map(&:join).max_by(&:length)
returnsnil
, which it will if the arraystrarr
is empty, then an empty string will be returned. Sincenil
is falsey,''
(the empty string) will be returned when the||
expression is evaluated on the last line—since strings are considered truthy. The first line of the method should handle cases wherestrarr
points to an empty string, but it's not bad to have a back up.what is the purpose of || "" at the end?
Wow this is amazing
each_cons is so good. but i don't want to using it.
It allows you to pass a method in as a symbol instead of passing in a block to the method itself, which makes it automatically reflexive without any further work. Below would be the longer version of the above example for that part.
i don't understand anything
This comment is hidden because it contains spoiler information about the solution