Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fields

These are the most common and fundamental pieces of data in the language.

They are a combination of four parts:

name = "Will";
favorite-things = [ "Movies" "Programming" ];
favorite-movie = {
    title = "Interstellar";
    director = "Christopher Nolan";
    release-year = 2014;
    leading-roles = [
        {
            character = "Joseph Cooper";
            actor = "Matthew McConaughey";
        }
        {
            character = "Dr. Amelia Brand";
            actor = "Anne Hathaway";
        }
    ];
};

In this example, there are 11 fields in total. Let's break down the biggest one:

favorite-movie = {
    title = "Interstellar";
    director = "Christopher Nolan";
    release-year = 2014;
    leading-roles = [
        {
            character = "Joseph Cooper";
            actor = "Matthew McConaughey";
        }
        {
            character = "Dr. Amelia Brand";
            actor = "Anne Hathaway";
        }
    ];
};

Here, there are nine total fields including the favorite-movies map. Within it, there are eight fields:

identifierassigned value
titlestring "Interstellar"
directorstring "Christopher Nolan"
release-yearnumber 2014
leading-rolesan list containing two maps as elements

The first element of leading-roles:

identifierassigned value
characterstring "Joseph Cooper"
actorstring "Matthew McConaughey"

The second element of leading-roles

identifierassigned value
characterstring "Dr. Amelia Brand"
actorstring "Anne Hathaway"

Important

It is an important distiction that the two elements within the leading-roles list are NOT fields; they are elements that contain fields.