# Re: Write Out Then Read In Hash of Two-element Arrays

**URL:** <https://www.ruby-forum.com/t/re-write-out-then-read-in-hash-of-two-element-arrays/58299>\
**Category:** Ruby\
**Created:** [April 20, 2006, 11:44am UTC](https://www.ruby-forum.com/t/re-write-out-then-read-in-hash-of-two-element-arrays/58299 "2006-04-20T11:44:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [April 20, 2006, 11:44am UTC](https://www.ruby-forum.com/t/re-write-out-then-read-in-hash-of-two-element-arrays/58299/1 "2006-04-20T11:44:08Z")

</div>

David B. wrote last Thursday, April 20, 2006 5:01 PM:  
…

# fileOut.puts(histHash[i])

```
                 ^^^^^

```

there is a problem here. consider…

irb(main):003:0\> puts [10,1]  
10  
1  
=\> nil  
irb(main):004:0\> puts [10,1].to\_s  
101  
=\> nil

i think you wanted the latter, so

fileOut.puts(histHash[i].to\_s)

should do.

some tips:

1 try unit test  
2 yaml  
3 marshal

kind regards -botp

---

<div class="post-metadata">

**Author:** ![PeSSSSaS\_Botp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ecd19e/32.png) [@PeSSSSaS\_Botp](https://www.ruby-forum.com/u/PeSSSSaS_Botp)\
**Post date:** [April 20, 2006, 8:51pm UTC](https://www.ruby-forum.com/t/re-write-out-then-read-in-hash-of-two-element-arrays/58299/2 "2006-04-20T20:51:36Z")

</div>

PeÃ±a, Botp wrote:

> David B. wrote last Thursday, April 20, 2006 5:01 PM:  
> …
> 
> # fileOut.puts(histHash[i])
> 
> ```
> ^^^^^
> 
> ```
> 
> there is a problem here. consider…
> 
> irb(main):003:0\> puts [10,1]  
> 10  
> 1  
> =\> nil  
> irb(main):004:0\> puts [10,1].to\_s  
> 101  
> =\> nil
> 
> i think you wanted the latter, so
> 
> fileOut.puts(histHash[i].to\_s)
> 
> should do.
> 
> some tips:
> 
> 1 try unit test  
> 2 yaml  
> 3 marshal
> 
> kind regards -botp

PeÃ±a,

Yes, that was what I needed. And I will look into yaml and marshal.  
Uh, how ro I find documentation about unit test? In any case, thank you  
very much.

David
