Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created April 3, 2011 15:44
Show Gist options
  • Select an option

  • Save ashmoran/900501 to your computer and use it in GitHub Desktop.

Select an option

Save ashmoran/900501 to your computer and use it in GitHub Desktop.
FAO @Ben_Nuttall :)
messages = [ "one,two,three", "un,deux,trois", "eins,zwei,drei" ]
File.open("messages.csv", "w") do |file|
messages.each do |message|
file.puts message
end
end
messages = [ "one,two,three", "un,deux,trois", "eins,zwei,drei" ]
file = File.open("messages.csv", "w")
begin
# This bit is the only thing that changes between different uses of a file
messages.each do |message|
file.puts message
end
ensure
file.close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment