I have the below code snippet:
line_sub = Regexp.new(/\s+|"|\[|\]/)
tmp = Array.new
# reading a file
while line = file.gets
...
tmp[0],tmp[1] = line.to_s.scan(/^.*$/).to_s.split('=')
#remove unwanted characters
tmp.collect! do |val|
val.gsub(line_sub, "")
end
...
end
but when I run the code I get the error:
undefined method `gsub' for nil:NilClass (NoMethodError)
something seems to be wrong here:
tmp.collect! do |val|
val.gsub(line_sub, "")
end
Any idea?
try this way for your solution