From: Tim Hunter Date: 2004-09-06T08:55:12+09:00 Subject: Re: nuby question rbrooks wrote: > Hello all, > > I just started looking at Ruby, and I really like what I see. I'm just at > the 'toying' stage at the moment, trying to learn the syntax, and adapt to > a new way of looking at code. I've got the following snippet that gives me > an error. I'm fairly certain that this will turn out to be a pretty dumb > question, but if I don't ask it, I'll never learn. Why does this: > > ... > i=0 > namelist.each do |aword| > if aword > namelist[i+1] > ... > end > i += 1 > end > ... > > give me the following error? > sortlist.rb:19:in '>': undefined method '>' for false:FalseClass > (NoMethodError) > > from sortlist.rb:19 > from:sortlist.rb:17:in 'each' > from:sortlist.rb:17 > > Thanks for any assistance, > > randy I don't know what's in your namelist array, but it looks to me like somehow it's gotten a 'false' value as one of the entries. Also, check out the each_with_index method in Enumerable.