From: brabuhr@... Date: 2006-11-21T12:24:26+09:00 Subject: Re: Bug in ruby? On 11/20/06, AliasX Neo wrote: > Well, I've spent the last hour or so debugging one of the stupidest > errors I have encountered with Ruby. > > Let's see my code first: > > [code]def parse(string, starting, ending) > istart = string.index(starting) + starting.length > iend = string.index(ending, istart) > return string.slice(istart, iend - istart) > end[/code] > > This function is called about 13 times in my entire script. It breaks on > the last one with this error: > > undefined method `+' for nil:NilClass > > Now, I have debugged the living hell out of this application. It's > breaking on the first line, stating that starting.length is a nil object > and that it can't perform a + operator in a nil object. The string > that's getting passed into starting is: Wouldn't it be string.index() that is Nil here: string.index(starting).+(starting.length) starting.length is a parameter to the '+' method being called on the result of index().