JacobC2
1/24/2008 8:24:00 PM
On Jan 23, 3:37 pm, Thomas Wieczorek <wieczo...@googlemail.com> wrote:
> Heya
>
> On Jan 23, 2008 6:49 PM, JacobC2 <jaco...@gmail.com> wrote:
>
> > I am writing a program that reads a text file and then dumps it into a
> > mysql database, the problem that I am having is that the array has
> > illegal characters in it so I need to do an escape_string or something
> > on it. but how could I do this on an array?
>
> You can use map! or collect! or their non-destructive brothers map and
> collect. collect/map apply a method to each element in the array and
> return a new array with the results.
>
> # lines is some array
> escaped = lines.map { |element| some_mysql_escape(element) }
Thanks that work.