# YAML symbols

**URL:** <https://www.ruby-forum.com/t/yaml-symbols/92410>\
**Category:** Ruby\
**Created:** [April 19, 2007, 8:20am UTC](https://www.ruby-forum.com/t/yaml-symbols/92410 "2007-04-19T08:20:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![braver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e57/32.png) [@braver](https://www.ruby-forum.com/u/braver)\
**Post date:** [April 19, 2007, 8:20am UTC](https://www.ruby-forum.com/t/yaml-symbols/92410/1 "2007-04-19T08:20:40Z")

</div>

YAML writes out Ruby symbols as !ruby/sym, e.g. :name =\> ‘John’  
becomes

!ruby/sym name: John

I write out megabytes of data, so I played with replacing !ruby/sym  
with a simple colon:

:name: John

– and it gets loaded back just as the !ruby/sym version!

Is there a way to instruct YAML to dump plain colon ‘:’ instead of "!  
ruby/sym "? Is reading back my version a guaranteed behavior?

Cheers,  
Alexy

---

<div class="post-metadata">

**Author:** ![braver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e57/32.png) [@braver](https://www.ruby-forum.com/u/braver)\
**Post date:** [April 19, 2007, 9:29am UTC](https://www.ruby-forum.com/t/yaml-symbols/92410/2 "2007-04-19T09:29:04Z")

</div>

Weird… which version of YAML are you using? It doesn’t generate !  
ruby/sym for me:

## $ ruby -v -r yaml -e ‘puts({:name =\> “John”, :yaml\_version =\> YAML::VERSION}.to\_yaml)’ ruby 1.8.4 (2005-12-24) [i486-linux]

:yaml\_version: “0.60”  
:name: John

---

<div class="post-metadata">

**Author:** ![braver](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/a88e57/32.png) [@braver](https://www.ruby-forum.com/u/braver)\
**Post date:** [April 19, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/yaml-symbols/92410/3 "2007-04-19T13:22:06Z")

</div>

On Apr 19, 12:28 pm, eden li [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On Apr 19, 2:20 pm, braver [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > – and it gets loaded back just as the !ruby/sym version!
> 
> > Is there a way to instruct YAML to dump plain colon ‘:’ instead of "!  
> > ruby/sym "? Is reading back my version a guaranteed behavior?
> 
> > Cheers,  
> > Alexy

Hi!  
Same here! It is not placing ! in my case as well. As per the  
YAML.rb documentation it should.
