Skip to content

Instantly share code, notes, and snippets.

@kevinhabits
Forked from coolaj86/README.md
Created June 18, 2013 20:52
Show Gist options
  • Save kevinhabits/5809251 to your computer and use it in GitHub Desktop.
Save kevinhabits/5809251 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require("json")
def save(name, stuff)
File.open(name, "w") { |f|
f.write(names.to_json)
}
end
def load(name)
return JSON.parse(f.read(name))
end
names = load("names.json")
save(names)
["Theo", "Megan", "Bryan", "Travis"]
#!/usr/bin/env ruby
require("json")
names = ["Theo", "Megan", "Bryan", "Travis"]
puts "puts \n"
puts names
File.open("my-stuff.puts", "w") { |f|
f.write puts names
}
puts "p \n"
p names
File.open("my-stuff.p", "w") { |f|
f.write(p(names))
}
puts names.to_json
puts "puts json \n"
File.open("my-stuff.json", "w") { |f|
f.write(names.to_json)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment