A
allan.m.miller
Hello,
I'm new to yaml, and yaml in Ruby.
I'm trying to create a yaml file in a text editor, one part of which
will consist of an array of of arrays. The data structure I'm trying
to represent is:
[['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']]
an array of three arrays.
I've tried to create this yaml file in a text editor (test.cfg):
-- a
- b
- c
-- d
- e
- f
-- g
- h
- i
and read it in as follows
require 'yaml'
na = open('test.cfg') { |f| YAML.load(f) }
I get a load error:
$ ./test.rb
/usr/lib/ruby/1.8/yaml.rb:119:in `load': parse error on line 9, col -1:
`' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:119:in `load'
from ./test.rb:3
from ./test.rb:3:in `open'
from ./test.rb:3
The last line seems o be causing an ArgumentError.
I'm sure my approach is completely off - how does one represent an
array of arrays in yaml, and load it into a Ruby array of arrays?
Thanks.
I'm new to yaml, and yaml in Ruby.
I'm trying to create a yaml file in a text editor, one part of which
will consist of an array of of arrays. The data structure I'm trying
to represent is:
[['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']]
an array of three arrays.
I've tried to create this yaml file in a text editor (test.cfg):
-- a
- b
- c
-- d
- e
- f
-- g
- h
- i
and read it in as follows
require 'yaml'
na = open('test.cfg') { |f| YAML.load(f) }
I get a load error:
$ ./test.rb
/usr/lib/ruby/1.8/yaml.rb:119:in `load': parse error on line 9, col -1:
`' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:119:in `load'
from ./test.rb:3
from ./test.rb:3:in `open'
from ./test.rb:3
The last line seems o be causing an ArgumentError.
I'm sure my approach is completely off - how does one represent an
array of arrays in yaml, and load it into a Ruby array of arrays?
Thanks.