From: Phillip Gawlowski Date: 2010-11-29T03:17:51+09:00 Subject: Re: Loading variables from a file [Noob Question] On Sun, Nov 28, 2010 at 6:44 PM, Richard Mccormack wrote: > Hey everyone, > It seems that there isn't a way to do this, > so I was wondering if there was a better way to manage the > saving/loading. Ruby 1.8.x ships with YAML, while Ruby 1.9.x includes JSON. Both formats allow you to save variables to file, and reload them. require "yaml" require "json" [1,2,3,4,].to_yaml [1,2,3,4,].to_json If you need something more complex, Marshall#dump and #load can be useful. All of this should be covered by the Ruby docs, too (at least YAML and Marshall are, JSON at 1.9.x, as I've mentioned). Mind, you still have to do the assignment and such yourself, but you get the data back in a Ruby-friendly format. ;) -- Phillip Gawlowski Though the folk I have met, (Ah, how soon!) they forget When I've moved on to some other place, There may be one or two, When I've played and passed through, Who'll remember my song or my face.