Matt R. wrote:
> I'm getting some strange behavior with YAML in ruby regarding the 
> characters '08' in a hash.
> 
> This code:
> #
> require 'yaml'
> test = { "08" => '01', '01' => '08', '8' => '01'
> }
> File.open("test.yml", "w") {|f| YAML.dump(test, f)}
> #
> 
> produces this file:
> ---
> "01": 08
> "8": "01"
> 08: "01"
> 
> I do not understand why the 08s are not quoted. I tried it under ruby 
> 1.8.2 and 1.8.4.
> 
> Is this expected?

I think so. The quotes are needed to disambiguate the string "01" from
the octal number. If quotes were not added by dump, then 01 would be
loaded as the fixnum 1 rather than the string "01". There's no ambiguity
with 08 because it is not legal octal, so it must be a string.

irb(main):004:0> YAML.load "foo: 08"
=> {"foo"=>"08"}
irb(main):005:0> YAML.load "foo: 07"
=> {"foo"=>7}
irb(main):006:0> YAML.load "foo: 017"
=> {"foo"=>15}

Note in the last case the conversion from octal.

-- 
      vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407