From: James Edward Gray II Date: 2007-06-11T22:20:24+09:00 Subject: Re: [QUIZ][SOLUTION] Mexican Blanket (#127) On Jun 10, 2007, at 10:39 AM, Will Bailey wrote: > Any feedback on how I can improve this code would be much appreciated. One idea came to me on a quick glance at the code... > ---------------------------------------------------------------------- > --------------------------------------- > @colors = > Hash > ["0","black","1","red","2","orange","3","yellow","4","green","5","blue > ","6","indigo","7","violet","8","white","9","grey"] First, you can drop a lot of punctuation from a line like this using Ruby's word Array syntax: @colors = Hash[ *%w[ 0 black 1 red 2 orange 3 yellow 4 green 5 blue 6 indigo 7 violet 8 white 9 grey ] ] Of course, those keys are just indices, and we should probably treat them as such: require "enumerator" @color = Hash[ *%w[ black red orange yellow green blue indigo violet white gray ]. enum_with_index.to_a.flatten.reverse ] I do realize that's not quite as readable though. James Edward Gray II