From: Zachary Holt Date: 2007-06-15T03:27:45+09:00 Subject: Re: Characters and strings oddness On Jun 14, 2007, at 11:01 AM, Stefan Kruger wrote: > Hi there Rubyists - Hi. > irb(main):002:0> string[0] == 't' string[0].chr == 't' or string[0] == ?t > delim = "\"" > string = delim > if line.gsub!(/^.*?(\")/, '') > (0..line.length).each do |i| > string << line[i] > break if i>0 && (line[i, 1] == delim) && (line[i-1, 1] != '\\') > end > end > > TypeError: can't convert nil into String > > method << in test.rb at line 9 > at top level in test.rb at line 9 > at top level in test.rb at line 8 > > I'm at a loss to understand why that gives an error. Try 0...line.length (three dots, not two). You're indexing past the end of the string.