Return to Snippet

Revision: 80601
at March 21, 2020 23:30 by chrisaiv


Updated URL
https://www.chrisjmendez.com/2007/10/21/converting-an-array-into-yaml-loading-yaml-into-an-array/

Updated Code
https://www.chrisjmendez.com/2007/10/21/converting-an-array-into-yaml-loading-yaml-into-an-array/

Updated Description
https://www.chrisjmendez.com/2007/10/21/converting-an-array-into-yaml-loading-yaml-into-an-array/

Revision: 4079
at October 21, 2007 19:56 by chrisaiv


Initial Code
#A. Import the YAML Library
require 'yaml'
#B. Create an array
names = %w[chris sandy josie billy suzie]

#Example 1 : Converting an array into YAML using: to_yaml
yaml_example1 = names.to_yaml
puts yaml_example1

#Example 2: Converting an array into YAML using: dump()
yaml_example2 = YAML::dump(names)
puts yaml_example2

#Example 3: Loading YAML back into an array using: load()
array_example = YAML::load(yamloutput2)
puts array_example

Initial URL

                                

Initial Description

                                

Initial Title
Converting an array into YAML, Loading YAML into an array

Initial Tags
ruby

Initial Language
Ruby