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.
I took it as implied that I was recreating zip. Not re-using it.
This comment is hidden because it contains spoiler information about the solution
I wondered the same thing, until I saw everyone else doing it. I am only just learning ruby.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Read up on the unary & operator. It's operating on the :capitalize symbol. Basically it's making the captialize method into a block.
It's leaning on functionality of
Symbol#to_proc
to do it. There's a few different pieces that make it up, and http://www.jacopretorius.net/2012/01/symbolto_proc-in-ruby.html seems to be a good in depth writeup of it.In short though:
&foo
in arguments passesfoo
as a block to the method as if you'd done{ foo.call }
. If foo isn't a proc, it callsto_proc
on it first.Symbol#to_proc
is implemented and creates a proc that sends the symbol to the block argument. That is:capitalize.to_proc
returns a proc (block) equivilent to{ |arg| arg.capitalize }
[].map { |element| element.capitalize }
can be written as[].map(&:capitalize)
and it returns the same result.