From: Lady Michelle Bhaal Date: 2005-11-19T20:26:20+09:00 Subject: Re: why is my array a hash? Thanks, now if I could only teach Vim to match do,end pairs the way it'll match braces Tim Hammerquist wrote: > Lady Michelle Bhaal wrote: >>I have a chunk of code, where I define an array, and the very >>next time I use it, Ruby thinks that it's a hash instead :( >> >>.. >>step = Array.new >>astep, line = getNextWord(line) >>while astep != nil >>{ >> step.push(astep) <- gets error 'odd number list for hash' >> astep, line = getNextWord(line) >>} >>.. >> >>What's with this? > > Ruby doesn't think step is a hash. > > The proper syntax for a while loop in ruby is: > > while CONDITION > ... > end > > Ruby is seeing your { } and interpreting them as a hash > definition, not a block as in other languages. > > while astep != nil > step.push(astep) > astep, line = getNextWord(line) > end > > HTH, > Tim Hammerquist