array_with_three_elements:
- 1
- 2
- 3
empty_array:
Is there any way to specify that empty_array: is an array with no elements, such as with []? When I load it into a ruby hash I'd like it to know that it's an array.
Try using [], like:
empty_array: []
So in Ruby you have:
x = YAML::load("empty_array: []")
x # => {"empty_array" => []}
[] works for an empty sequence, "" works for an empty string, and {} works for an empty mapping.empty_array:[] resulted in a parser error. It apparently only happens in certain contexts. YAML::load("empty_array:[]") works, YAML::load("{empty_array:[]}") fails, and YAML::load("{empty_array: []}") also works. Beware of whitespace in yaml.