Minute Five: Is That All???

At this point it may seem like there isn't much to YAML. It's just a bunch of lists and dictionaries?

Well, these are just the basics here and our five minutes are about up. Before we go, one last concept.

Here's one person's record of how long their trip through this tutorial took:

---
name: Dirk Hockeybranch
minutes spent: 
 - 1.02
 - 1.34
 - 0.7
 - 0.89
 - 0.94

Above we have a list (sequence) nested inside of a dictionary (map). Each item in the list represents the number of minutes spent on each page. If everyone sent us documents describing their time like this, then we could compile a more accurate name for this tutorial. Such as: YAML in Five-Point-One-Two Minutes. That would be pretty slick.

One very smart YAML user decides to use an inline sequence to record their time:

---
name: Dirk Hockeybranch
minutes spent: [1.02, 1.34, 0.7, 0.89, 0.94]

For short lists, you can simply put the entire list on a single line. Separate it by commas and put brackets around it.

Inline maps are also available:

---
minutes spent: {one: 1.02, two: 1.34, three: 0.7,
                four: 0.89, five: 0.94}

Please beware, though. Blocks are not available in inline sequences or maps.

Conclusion

Check the time. Where are we at now? Five minutes? Ten minutes?

Now it's your turn to write some YAML! Add a comment below with your time to compelte the list! For extra credit, you can add a key called comments with your reaction to this tutorial.

If you'd like to further your study of YAML, I'd suggest taking a look at the YAML Cookbook. The Cookbook will go into more detail on each of the concepts above. I think you'll be surprised at how much more YAML has to offer.

Most of all: thanks for your time!

Want to learn more? YamlTheSecondFiveMinutes

Last edited Dec 21, 2009 at 9:11 PM by BurtHarris, version 3

Comments

No comments yet.