From: rbrooks Date: 2004-09-06T09:10:16+09:00 Subject: Re: nuby question Tim, Thanks for responding. namelist is just a list of words that I was then going to sort. I realize Ruby has a sort method for arrays that takes care of this very easily, (took me about half a second to figure that out and get it to work, but I was just trying to hand code it to get more familiar with the language. Sure it's nothing I would ever use again, but I find the more I keep working with a language the quicker I begin to grasp it and can begin to do something useful with it. Not sure if the each_with_index method would help me here, but it seems apparent that I need to really study Enumerable. Thanks, randy "Tim Hunter" wrote in message news:gGN_c.5619$ay.769217@twister.southeast.rr.com... > 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.