From: Alan Johnson Date: 2008-11-20T05:46:29+09:00 Subject: Re: Implicit Conversion On Wed, Nov 19, 2008 at 12:35 PM, Demetirck Demetrickn wrote: > Hello all, > I'm new to this site I'm an intern at software company and was given the > task of writing a program in ruby that simply could open data files > check for a particular field in the text file and compare the intger > agains't a mininum value. > > I seem to be getting a prblem from ruby that says > " `[]': no implicit conversion from nil to integer (TypeError)" > > Ruby doesn't seem to let me give integer values to an array inside a > loop. > Is there anyway I can static cast or do a type conversion in ruby ? > -- > Posted via http://www.ruby-forum.com/. > > It doesn't sound like your error is necessarily what you think it is. That error happens when you do something like: a = [1, 2, 3, 4, 5] i = nil a[i] You can convert most objects (including nil) to an integer with the to_i method, but that probably isn't going to fix anything. nil.to_i is always 0. Post some code and someone here will likely be able to spot your error.