[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

YAML to anchor same strings in dumps

Gennady Bystritsky

1/30/2009 5:32:00 AM

Hi, there

Is there any way to make YAML alias same strings in dumps? The following co=
de fragment:

require 'yaml'
s =3D 'a' * 10
puts [ s, s ].to_yaml

Produces this:
---
- aaaaaaaaaa
- aaaaaaaaaa

While I need:
---
- &id001 aaaaaaaaaa
- *id001

Interestingly, if I define s as:
s =3D [ 'a' * 10 ]

The output is aliased just fine:
---
- &id001
- aaaaaaaaaa
- *id001

Thanks,
Gennady.