03 May '12, 2pm

My latest blog post for @thoughtbot contains a late-90s rap video, the golden age of the fisheye lens

May 3, 2012 Tagged: inject enumerable refactoring arrays ruby Comments (View) Come Correct with Inject and Collect Here’s a refactoring example for a simple Ruby math problem using the inject method. The goal is to generate an n by n multiplication matrix. Pretty straightforward. Let’s make a first pass: def multiplication_table(n) results = [] (1..n).each do |row_index| row = [] (1..n).each { |column_index| row << row_index * column_index } results << row end results.each do |row| header = '%-3s ' * row.length puts header % row end end multiplication_table(7) 1 2 3 4 5 6 7 2 4 6 8 10 12 14 3 6 9 12 15 18 21 4 8 12 16 20 24 28 5 10 15 20 25 30 35 6 12 18 24 30 36 42 7 14 21 28 35 42 49 It does the job, but it’s nothing to look at. We can condense using in-line blocks and fancy curly braces, but first let’s try using inject . Quick background: Inject iterates over a set usi...

Full article: http://robots.thoughtbot.com/post/22319029309/come-correc...

Tweets

If you missed Maifest at Clarke Quay tonight, c...

superadrianme.com 04 May '12, 3pm

Boyz Nite Out K Pop Festival: Jay Park, SHINee and more Posted On Monday, April 30, 2012 By Adrian . Under Event , Music T...

articles on abortion

articles on abortion

greenbuildingelements.com 04 May '12, 7am

WOMEN DESERVE COMPASSIONATE JUSTICES The Roanoke Times (Roanoke, VA) July 12, 2009 | Richard C. Bryant All the recent arti...

I get quite a few guest post requests but normally turn them down as they are usually generic and opportunistic....

I get quite a few guest post requests but norma...

ronisweigh.com 03 May '12, 2am

My name is Amanda from Survival Guide by The Working Mom and this is my story. Obesity sounds like such a harsh word. It i...

#Hollande "83 morts en Afghanistan" CORRECT #Le...

defense.gouv.fr 02 May '12, 9pm

Grand texte Petit texte Ajouter aux favoris Envoyer à un ami Retour Mise à jour : 27/03/2012 15:57 Ce mémorial honore la ...

iCrossing Tops Search Agency Revenue Rankings I...

searchengineland.com 03 May '12, 9pm

New York-based iCrossing, a division of Hearst Corporation, tops the latest Ad Age list of top 25 search marketing agencie...