Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "yaml"
- fname = "hash_output.txt"
- hsh = {
- "test" => "foo",
- "test2" => "foo2"
- }
- #save to file...
- File.open(fname, "w"){|fo|
- fo << YAML.dump(hsh)
- }
- hsh2 = {}
- #load from file...
- File.open(fname, "r"){|fo|
- hsh2 = YAML.load(fo)
- }
- #test new hash...
- hsh2.each{|k, v|
- puts "#{k} => #{v}"
- }
Add Comment
Please, Sign In to add comment