From: Li Chen Date: 2009-09-26T23:56:39+09:00 Subject: Re: How to remove duplicate elements in a 2D array Thairuby ->a, b {a + b} wrote: > The method ".map(&:flatten)" is use to converse hash back to array. Thanks. But I still have some doubts about this line: result = arr.inject({}){|x,y| x[y[0]]=y[1..-1]; x }.map(&:flatten) 1) When I look at #inject method, I notice it only takes either no augument or an augument with initial value. But in your code it takes a hash. It is kind of new/strange to me. 2) Why do you write an x alone after this line x[y[0]]=y[1..-1]; ? 3) #map(&:flatten) doesn't work in my Ruby version(1.8.6). Which version are you using? But I make some changes and it works. result = arr.inject( { } ){|x,y| x[y[0]]=y[1..-1]; x}.to_a r=result.collect { |row| row.flatten} Li -- Posted via http://www.ruby-forum.com/.