Name this function:

  inject({}) { |h, o| h[yield(o)] = o; h }.values

Hints:

  1. It’s a variant of a common stdlib function.
  2. The name has 7 characters, one of which is an underscore.

A survey of my rubyist colleagues suggests this is a hard question. Much harder than writing the function given the name, which took about 10 seconds.

William Morgan, June 13, 2008.
This article was labeled as

Comments

To reply to the article, enter your email address. A copy of the article will be sent to you via email.