Hi, I just read about the “.write” method.
Let’s say that I’ve just written a string to a file, “file.txt”. Then I
want
to add some more information to it, on the next line. I use .write again
and
my info got replaced. How do I add to the without deleting what’s
already in
it. I know I can load the string from it and then add them together, but
isn’t there a smarter way to do it, like writing to the next line?
Hi, I just read about the “.write” method.
Let’s say that I’ve just written a string to a file, “file.txt”. Then I want
to add some more information to it, on the next line. I use .write again and
my info got replaced. How do I add to the without deleting what’s already in
it. I know I can load the string from it and then add them together, but
isn’t there a smarter way to do it, like writing to the next line?
Thanks in advance
Look up the “append” option for File when opening for writing.
–
James B.
“Programs must be written for people to read, and only incidentally
for machines to execute.”
H. Abelson and G. Sussman
(in "The Structure and Interpretation of Computer Programs)
Hi, I just read about the “.write” method.
isn’t there a smarter way to do it, like writing to the next line?
"Programs must be written for people to read, and only incidentally
–
Daniel B. http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
Things
That Suck)
[[My webhost uptime is ~ 92%… if no answer pls call again later!]]
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.