Stefan Tilkov's Random Stuff

The Methodphitamine

Jay Phillips:

I call it The Methodphitamine. That’s Method ph it amine, a drug for Ruby addicts to code faster.

This allows you to shorten

User.find(:all).map{|x| x.contacts.map{|y| y.last_name.capitalize }}

to

User.find(:all).map &its.contacts.map(&its.last_name.capitalize)

Despite the stupid name, this is definitely a cool hack. I’m not entirely I’d ever actually use this, but I still find it great to find out the language supports stuff like this :-)