From: Muhammad Salman Date: 2012-10-11T02:34:45+09:00 Subject: Re: How to create an Array in a Hash Hans Mackowiak wrote in post #1079276: > 1) > this line replaces all your other posted lines. > so you have this: > > anagram_array = words.uniq.group_by{|w| > w.downcase.each_char.sort}.values > > 2) > uniq removes the second scream > group_by wants a block > w.downcase.each_char.sort makes an array of chars so "Cars" will be > turned to ["a","c","r","s"] > > so we have: > { > ["a", "c", "r", "s"]=>["cars", "scar"], > ["f", "o", "r", "u"]=>["four"], > ["a", "c", "e", "m", "r", "s"]=>["creams", "scream"] > } > > but you only want the values, so i add .values Thanks, i removed uniq and did what you said and got exactly what i was looking for. This is soo cool i never thought that only a line could be soo powerful :) -- Posted via http://www.ruby-forum.com/.