From: Holden Holden Date: 2008-01-04T08:49:54+09:00 Subject: Troubles with blocks Hi, I am a Python programmer and I've just started learning Ruby. Until now, I've enjoyed it, but I am having troubles with some methods that require blocks. This is a simple example that (I expect) summarizes my problems - how to obtain a list of pairs [index, value] (or [value, index], it doesn't matter) from an array: 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? thanks -- Posted via http://www.ruby-forum.com/.