From: Tim Hammerquist Date: 2005-11-19T20:17:22+09:00 Subject: Re: why is my array a hash? 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 -- Show me something that beats a Natural Twenty, and I'll show you hateful LIES! -- Red Mage, 8-Bit Theater