I am new to YAML and Ruby. I use the following Ruby code to parse the YAML file:
obj = YAML::load_file('test.yml')
Are the following contents of the YAML file for 'test.yml' valid?
Case 1:
test
In this case, I do not specify the value of test (something like test : true ), but my Ruby parsing code does not throw an error. I thought this was an invalid YAML syntax.
Case 2:
:test : true
In this case, the Ruby code treats test as a character instead of a string, and when I do puts obj[:test] , it returns the result as "true". Is this a ruby thing? Do other languages interpret it as the string ":test" ?
Case 3:
:test : true :test : false
In this case, instead of throwing an error to override :test , my Ruby code takes the most recent value for :test (which is false ). Why is this? Is the YAML syntax to allow overriding of elements, in which case only the last value is taken?
source share