From: james.d.masters@... Date: 2007-05-04T02:45:05+09:00 Subject: Re: Array to Hash On May 3, 10:17 am, s...@seebs.net (Peter Seebach) wrote: > In message , Chris Browne writes: > > >array = [ nil, "b", nil, nil, nil , "f", "g", nil, nil, "j"] > >hash = {} > >array.each_with_index { |value, index| hash[index] = value unless ! value } > >puts hash.inspect > > My code was very similar to this. > > 5 quatloos to the first person to find a hypothetical case where this code > produces the wrong answer. When values are false. Replace condition from "! value" to "value.nil?".