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.
it is the first match
but you probably know it by now :-)
The letter after the underscore/hyphen matched in the regex.
There are brackets around the full stop, those brackets are what you can reference with
$1
and so on.It's a shortcut for
value = value || another_value
Just like += is a shortcut for
x = x + y
It's Ruby's "conditional assignment operator". It only assigns the value to a variable if it is nil (or false), otherwise it doesn't do anything. It is necessary in this case to preserve the values in @cache every time the fibonacci method is called. If it was a simple assignment operator, @cache would get an empty hash assigned to it when fibonacci is called, and the solution wouldn't work.
This comment is hidden because it contains spoiler information about the solution
No good reason, thanks for the comment
I just think it reads nice there. IFAIK the only difference between
||
andor
is precedence, which doesn't matter there.