rebolred-langrebol2

What is the best way to save a hash! block in Rebol?


I am using Rebol2 and would like to persist a HASH! block.

Currently I am converting it to-string then using save.

Is there a better way? For example:

r: make hash! ["one" "two"]

I want to save this to a file, then load it back to r.


Solution

  • you are very near your goal. Just use save/all and load

    >> r: make hash! ["one" "two"]
    == make hash! ["one" "two"]
    >> save/all  %htest r
    >> r: load %htest
    == make hash! ["one" "two"]
    

    If you want the same result in Red you just need one command more

    >> r: do load %htest
    == make hash! ["one" "two"]