From: David Bailey Date: 2006-04-21T00:29:26+09:00 Subject: Re: Write Out Then Read In Hash of Two-element Arrays Kroeger, Simon (ext) wrote: > Well, > > your primary problem is that you write both elements of the > arrays on separat lines. When reading you will read more > lines than you expect (twice as much to be correct). > > So an easy fix would be to write using > > fileOut.puts histHash[i].join(',') > > so both values are on the same line. > If you read them in you have to split the line to get two > distinct values again. > > fileIn.each_line{|line|histHash[i]= line.split(',').map{|s| s.to_i}} > > that said, I would recommend having a close look at yaml. > > cheers > > Simon Simon, Thank you. Your suggestion, of course, worked. Why I oddly thought Ruby should split the hash elements into separate lines, but not the its array elements, I'll never know! After being up all night, I guess my brain just stopped working. I've seen the acronym yaml around a few times, but short a guessing that it means yet another meta language I do not know what it actually does, but I will take a look at it as you suggest. Again, thank you. I'm awake now! (:>) David -- Posted via http://www.ruby-forum.com/.