News for hackers. Stuff that matters.
Re:(1..100).inject(&:+) by wvenable on Monday February 25, 2008 @03:13PM (#123290)
I'm not a ruby programmer and it's not immediately obvious what the result would be.

I know a pretty large number of languages to the point where, unless it's LISP, I can look at code in any language and have some idea of what it does. When a languages gets "so cool" that it's cryptic than I no longer see the benefit.

Re:(1..100).inject(&:+) by raganwald on Monday February 25, 2008 @03:19PM (#123297)
Would (1..100).fold(&:+) be more obvious? How about (1..100).reduce(&:+)? If either one of those makes sense, perhaps it is a question of Matz choosing Smalltalk's names for methods (collect, select, detect, reject, inject).

Please let me know if changing the name of the method doesn't help.

Re:(1..100).inject(&:+) by spydez on Monday February 25, 2008 @03:56PM (#123332)
A little explanation in your article would've been fine. The non-ruby people in the crowd have no clue what "&:+" does, so you lost us really early on when you neglected to explain your fancy one-liner.

'inject' makes sense (in retrospect), but until it was explained, I had no clue why injecting symbol soup into a range of integers was interesting.

Re:(1..100).inject(&:+) by raganwald on Monday February 25, 2008 @03:59PM (#123335)
"I had no clue why injecting symbol soup into a range of integers was interesting."

Lisp flavours?

"A little explanation in your article would've been fine."

Done, thank you.