Coming from a amature javaScripter, Ruby is amazing. It can do things that almost make it too easy. I am constantly learning things that make me think “Why are’t other languages this easy and helpful!”. Doing a lab here at Flatiron an instructor helped me do somehing I have’t seen anywhere thus far. It blew my mind so much I decided to 1) Name this blog after it and 2) write the first entry about it.
You can chain blocks with other methods and even other blocks! I cannot believe you can do this and It is AMAZING!
The code looks something like this:
hash[:nest]["Randy"].sort{ |x,y| y <=> x }.select{ |z| z > 99 }
So here I am opeing an array in a nested hash named after me, within a nested hash named, wait for it, :nest, within a hash named, you guessed it, hash. I’m sorthing that array. Then I’m selected any values over 100 in that array. That is the idea. I understand that this is redundant code however the idea still stands. Take it and run with is. I completely love it.