Arrays are available in almost all programming languages, including Perl
, Python
, PHP
, Java
, C#
, Ruby
, and JavaScript
. They are linear data types used to represent a list of items.
In YAML
data serialization format, you can represent arrays using two different styles, as explained below.
The block sequence style of YAML
uses hyphens or dashes to (-
) to represent arrays. A hyphen (-
) followed by white space (
) represents an element of an array. When you enter the dashes, you need to ensure that all items are at the same indentation level.
See the code example below to understand this better.
colors:
- red
- green
- blue
- orange
The flow sequence style of YAML
uses brackets and commas to represent arrays.
See the code example below to understand this better.
colors: [red, green, blue, orange]
Learn more about syntax, data types, and critical concepts related to
YAML
language through this mini-course.
RELATED TAGS
CONTRIBUTOR
View all Courses