raw file
---
:jamy:
:email: jamy.rustenburg@gmail.com
:interests:
- woodworking
- cooking
- reading
:nora:
:email: nora.alnes@yahoo.com
:interests:
- cycling
- basketball
- economics
:hiroko:
:email: hiroko.ohara@hotmail.com
:interests:
- politics
- history
- birding
output:
{:jamy=>{:email=>"jamy.rustenburg@gmail.com", :interests=>["woodworking", "cooking", "reading"]},
:nora=>{:email=>"nora.alnes@yahoo.com", :interests=>["cycling", "basketball", "economics"]},
:hiroko=>{:email=>"hiroko.ohara@hotmail.com", :interests=>["politics", "history", "birding"]}}
If you call YAML.load_file(file) then the above output is generated.
- Builds a bigger hash with (:jamy, :nora, :hiroko) as keys.
- then builds another hash with :email and :interests as keys.
- then the ("-") will build an array of strings.
---
:jamy:
:email: jamy.rustenburg@gmail.com
:interests:
- woodworking
- cooking
- reading
:nora:
:email: nora.alnes@yahoo.com
:interests:
- cycling
- basketball
- economics
:hiroko:
:email: hiroko.ohara@hotmail.com
:interests:
- politics
- history
- birding
output:
{:jamy=>{:email=>"jamy.rustenburg@gmail.com", :interests=>["woodworking", "cooking", "reading"]},
:nora=>{:email=>"nora.alnes@yahoo.com", :interests=>["cycling", "basketball", "economics"]},
:hiroko=>{:email=>"hiroko.ohara@hotmail.com", :interests=>["politics", "history", "birding"]}}
If you call YAML.load_file(file) then the above output is generated.
- Builds a bigger hash with (:jamy, :nora, :hiroko) as keys.
- then builds another hash with :email and :interests as keys.
- then the ("-") will build an array of strings.
Comments
Post a Comment