This is my Ruby code:
require 'yaml'
yaml = YAML.parse(
'''
foo: "hello, world"
'''
)
puts yaml['foo']
I'm getting:
NoMethodError: undefined method `[]' for #<Psych::Nodes::Document:0x007f92a4404d98>
It's Ruby 2.1.3
You should use YAML.load
instead of YAML.parse
according to documentation to parse the YAML.
require 'yaml'
yaml = YAML.load(
'''
foo: "hello, world"
'''
)
puts yaml['foo']
# => hello, world
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With