From: MenTaLguY Date: 2008-01-04T09:13:17+09:00 Subject: Re: Troubles with blocks On Fri, 4 Jan 2008 08:49:54 +0900, Holden Holden wrote: > Python: > > list(enumerate(['a','b','c'])) > => [(0, 'a'), (1, 'b'), (2, 'c')] > > 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? Try this (you will need to require 'enumerator'): ['a','b','c'].enum_with_index.to_a -mental