This is a single archived entry from Stefan Tilkov’s blog. For more up-to-date content, check out my author page at INNOQ, which has more information about me and also contains a list of published talks, podcasts, and articles. Or you can check out the full archive.

The Methodphitamine

Stefan Tilkov,

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 :-)