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?
nice catch
Neat! Can you explain your logic here?
The last few characters of this solution are unnecessary.
Works fine without || "" at the end of second line.
It took me a second, but this is brilliant.