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.
Not an issue
That's a good call.
It took me a while to figure out what's happening here. In case anyone else is interested.
Basically, any Regexp without closed parentheses will throw an exception, which Insti rescues by returning false. Tricky.
Just punch this in your repl:
The trickier part is tilde. I found the answer here - Stackoverflow & Ruby Regexp Docs very last method #~
It's matching the Regexp to the last 'gets' prompt (only if it's valid, i.e., only if it has closed or no parenthesis). The variable $_ holds the most recent and scoped value of gets, which, in the case of #valid_parentheses is nothing, nada, nil.
For illustration:
I like this. Your loop is elegant.
My confusion mostly stems from how many other alternative solutions people come up. Lots of 'calls' and 'yields'. I'm very green at ruby, so these techniques appear to be some kind of black magic.
Am I correct in saying the purpose of these exercises is to more or less be aware that these methods exist. It's like saying, here's how you can wash your boots:
def washboots boots
boots.washboots
end
washboots(myboots)
Sweet, its nice to know I can wash my boots. But I don't feel so special the way I went about it.
I do not intend to disparage the authors work. I'm just trying to make sure I'm not missing something.
Doesn't this defeat the purpose of desiging the ins and outs of your own drop method?
It should be specified that a 'return' is vital. I punched this code sans return into another interpreter and it came out no problem. It was until I 'return'ed my hash at the end of the method did the test accept it.