Ok, I tried to delete lines that contain -- from a file. The file looks like this:
-----------------------------------------------------------------
Lorem ip
So whats going on?
Something like this:
line = "-----------------------------------\n"
=> "-----------------------------------\n"
a = line
=> "-----------------------------------\n"
line.delete a
ArgumentError: invalid range "--
" in string transliteration
The error raised by the delete
method is because dashes are used for special character-range syntax:
"hellob".delete "a-e"
=> "hllo"
Probably you want to be taking a different approach to solve your goal, but it is difficult to tell what you want, as you don't show what you want to do with the data once lines are removed. Simply processing the line
variable just means you have an altered String
at that point.