News for hackers. Stuff that matters.
Re:Joel Spolsky: Can your programming language do this? by Peaker on Saturday April 23, 2011 @12:15PM (#2477054)
What would it do on an empty list? It should probably take an argument for the empty case...

What is the history behind the name "inject" here?

Re:Joel Spolsky: Can your programming language do this? by kragen on Saturday April 23, 2011 @01:33PM (#2477186)
The name comes from Smalltalk. I imagine that the idea is that you're "injecting" an operator between items in the list: 1 2 3 4 becomes 1 + 2 + 3 + 4.
Re:Joel Spolsky: Can your programming language do this? by kejadlen on Saturday April 23, 2011 @12:31PM (#2477078)
By default, inject uses the first element of the array as the argument, so it would use nil on an empty list. It optionally takes an argument to kick off the process.