Hi, I know you can write to a file using ‘w’, but this erases all the
previous data. How can I add new items to an existing document without
losing the data?
Thanks!
Hi, I know you can write to a file using ‘w’, but this erases all the
previous data. How can I add new items to an existing document without
losing the data?
Thanks!
Justin To wrote:
Hi, I know you can write to a file using ‘w’, but this erases all the
previous data. How can I add new items to an existing document without
losing the data?Thanks!
Use “a” instead of “w”. That will Append new data to the end of the
file.
On Wed, Jun 25, 2008 at 11:48 AM, Justin To [email protected] wrote:
Hi, I know you can write to a file using ‘w’, but this erases all the
previous data. How can I add new items to an existing document without
losing the data?
filename = File.open(“test”,“a”) do |f|
f.puts “append to file”;
f.close();
end
Hi again, how do I delete an item?
Thank you!
Justin To wrote:
Hi again, how do I delete an item?
…delete an item and take the now empty line away
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs