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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Peña, Botp (Guest)
on 2006-04-20 13:44
(Received via mailing list)
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
David B. (Guest)
on 2006-04-20 22:51
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
This topic is locked and can not be replied to.