From c1949a99b0a07b5a4c90e869e9624d6f24f5a49d Mon Sep 17 00:00:00 2001 From: Nikola Irinchev Date: Fri, 17 May 2024 14:05:28 +0200 Subject: [PATCH] Update amending example in tutorial (#491) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update amending example * Make sure wood pigeon amends stock pigeon Co-authored-by: Philip K.F. Hölzenspies --------- Co-authored-by: Philip K.F. Hölzenspies --- .../pages/02_filling_out_a_template.adoc | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/docs/modules/language-tutorial/pages/02_filling_out_a_template.adoc b/docs/modules/language-tutorial/pages/02_filling_out_a_template.adoc index 9b40880a..1f4fc3f5 100644 --- a/docs/modules/language-tutorial/pages/02_filling_out_a_template.adoc +++ b/docs/modules/language-tutorial/pages/02_filling_out_a_template.adoc @@ -75,22 +75,25 @@ Consider the following example. [source,{pkl}] .nestedAmends.pkl ---- -woodPigeon { - name = "Common wood pigeon" +stockPigeon { + name = "Stock pigeon" diet = "Seeds" taxonomy { - species = "Columba palumbus" - } -} - -stockPigeon = (woodPigeon) { - name = "Stock pigeon" - taxonomy { // <1> + kingdom = "Animalia" + clade = "Columbimorphae" + order = "Columbiformes" species = "Columba oenas" } } -dodo = (stockPigeon) { // <2> +woodPigeon = (stockPigeon) { + name = "Common wood pigeon" + taxonomy { // <1> + species = "Columba palumbus" + } +} + +dodo = (woodPigeon) { // <2> name = "Dodo" extinct = true // <3> taxonomy { @@ -103,7 +106,7 @@ dodo = (stockPigeon) { // <2> <3> New fields can be added to objects when amending. Notice how you only have to change `taxonomy.species`. -In this example, `bird.taxonomy` has `kingdom`, `clade`, `order` and `species`. +In this example, `stockPigeon.taxonomy` has `kingdom`, `clade`, `order` and `species`. You are amending `stockPigeon`, to define `woodPigeon`. They have the same `taxonomy`, except for `species`. This notation says that everything in `taxonomy` should be what it is in the object you are amending (`stockPigeon`), except for `species`, which should be `"Columba palumbus"` . @@ -111,27 +114,36 @@ This notation says that everything in `taxonomy` should be what it is in the obj For the input above, Pkl produces the following output. [source,{pkl}] ---- -woodPigeon { - name = "Common wood pigeon" - diet = "Seeds" - taxonomy { - species = "Columba palumbus" - } -} stockPigeon { name = "Stock pigeon" diet = "Seeds" taxonomy { + kingdom = "Animalia" + clade = "Columbimorphae" + order = "Columbiformes" species = "Columba oenas" } } +woodPigeon { + name = "Common wood pigeon" + diet = "Seeds" + taxonomy { + kingdom = "Animalia" + clade = "Columbimorphae" + order = "Columbiformes" + species = "Columba palumbus" + } +} dodo { name = "Dodo" diet = "Seeds" - extinct = true taxonomy { + kingdom = "Animalia" + clade = "Columbimorphae" + order = "Columbiformes" species = "Raphus cucullatus" } + extinct = true } ----