From: Robert Klemme Date: 2009-10-31T21:50:05+09:00 Subject: Re: file open failure test On 10/31/2009 10:02 AM, Simon Krahnke wrote: > * Robert Klemme (2009-10-27) schrieb: > > Just to play around with ruby 1.9: > >> DAYS = %w{Sun Mon Tue} # ... > > You can construct the hash doing the opposite translation with: > > DAYS_TO_I = DAYS.each_with_index.inject({}) { | h, (v, i) | h[v] = i; h }.freeze > > Any more simple way to do that? Not that I'm aware of. With a Hash you could use #invert but that is not available for Array it seems. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/