From: Justin Collins Date: 2006-11-21T12:26:54+09:00 Subject: Re: Bug in ruby? AliasX Neo wrote: > Well, I've spent the last hour or so debugging one of the stupidest > errors I have encountered with Ruby. > > > I debugged the application and put a mark on the first line to examine > it in the following code: > > [code]def parse(string, starting, ending) > length = starting.length > istart = string.index(starting) + length > iend = string.index(ending, istart) > return string.slice(istart, iend - istart) > end[/code] > > And the debugger said that length was an int with the value of 15. Guess > what still happened? Got the exact same error with the + operator on a > nil object. Except that completely contradicts the fact that it's not > nil but it's an int with the value of 15. > + is being called on string.index(starting) not length. I'd check to make sure you aren't getting nil from that: def parse(string, starting, ending) p string.index(starting) istart = string.index(starting) + length iend = string.index(ending, istart) return string.slice(istart, iend - istart) end Hope that helps. -Justin