From: Gary Wright Date: 2008-01-04T09:09:14+09:00 Subject: Re: Troubles with blocks On Jan 3, 2008, at 6:49 PM, Holden Holden wrote: > Ruby: > > t = []; ['a','b','c'].each_with_index { |*x| t << x }; t > => [["a", 0], ["b", 1], ["c", 2]] > > Which is a very ugly solution. How could I do this on Ruby without a > temporal variable? In Ruby 1.8: require 'enumerator' %w{a b c}.enum_for(:each_with_index).to_a In Ruby 1.9: %w{a b c}.each_with_index.to_a Gary Wright