On Fri, Sep 16, 2011 at 5:03 PM, Kassym Dorsel <k.dorsel / gmail.com> wrote:

> I have an array of strings that I need to modify. I either need to
> replace the string or delete the entry altogether. The only way I have
> been able to do this is :
>
>
> arr.delete("")
>
> (0..arr.size).each do |i|
>  if arr[i].to_i == 1201
>    arr[i]=arr[i].to_s[8..-1].gsub(/"[^"]*"/,'::').gsub(/".*/,"::")
>  else
>    arr[i-1] = arr[i-1] + arr[i].to_s[4..-1].to_s.gsub(/\s*/,"")
>    arr[i]=nil
>  end
> end
>
> arr.delete(nil)
>
>
> Is there a better way ?
>
>
> Also inside the else I get char 4->-1 of a string, but then need to
> explicitly change it into a string for gsub to work. Otherwise it gives
> me an undefined method 'gsub' for nilNilClass error.
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
I honestly have no idea what this is supposed to do.