Update amending example in tutorial (#491)

* Update amending example

* Make sure wood pigeon amends stock pigeon

Co-authored-by: Philip K.F. Hölzenspies <holzensp@gmail.com>

---------

Co-authored-by: Philip K.F. Hölzenspies <holzensp@gmail.com>
This commit is contained in:
Nikola Irinchev
2024-05-17 14:05:28 +02:00
committed by GitHub
parent d0def765a2
commit c1949a99b0

View File

@@ -75,22 +75,25 @@ Consider the following example.
[source,{pkl}] [source,{pkl}]
.nestedAmends.pkl .nestedAmends.pkl
---- ----
woodPigeon { stockPigeon {
name = "Common wood pigeon" name = "Stock pigeon"
diet = "Seeds" diet = "Seeds"
taxonomy { taxonomy {
species = "Columba palumbus" kingdom = "Animalia"
} clade = "Columbimorphae"
} order = "Columbiformes"
stockPigeon = (woodPigeon) {
name = "Stock pigeon"
taxonomy { // <1>
species = "Columba oenas" species = "Columba oenas"
} }
} }
dodo = (stockPigeon) { // <2> woodPigeon = (stockPigeon) {
name = "Common wood pigeon"
taxonomy { // <1>
species = "Columba palumbus"
}
}
dodo = (woodPigeon) { // <2>
name = "Dodo" name = "Dodo"
extinct = true // <3> extinct = true // <3>
taxonomy { taxonomy {
@@ -103,7 +106,7 @@ dodo = (stockPigeon) { // <2>
<3> New fields can be added to objects when amending. <3> New fields can be added to objects when amending.
Notice how you only have to change `taxonomy.species`. 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`. You are amending `stockPigeon`, to define `woodPigeon`.
They have the same `taxonomy`, except for `species`. 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"` . 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. For the input above, Pkl produces the following output.
[source,{pkl}] [source,{pkl}]
---- ----
woodPigeon {
name = "Common wood pigeon"
diet = "Seeds"
taxonomy {
species = "Columba palumbus"
}
}
stockPigeon { stockPigeon {
name = "Stock pigeon" name = "Stock pigeon"
diet = "Seeds" diet = "Seeds"
taxonomy { taxonomy {
kingdom = "Animalia"
clade = "Columbimorphae"
order = "Columbiformes"
species = "Columba oenas" species = "Columba oenas"
} }
} }
woodPigeon {
name = "Common wood pigeon"
diet = "Seeds"
taxonomy {
kingdom = "Animalia"
clade = "Columbimorphae"
order = "Columbiformes"
species = "Columba palumbus"
}
}
dodo { dodo {
name = "Dodo" name = "Dodo"
diet = "Seeds" diet = "Seeds"
extinct = true
taxonomy { taxonomy {
kingdom = "Animalia"
clade = "Columbimorphae"
order = "Columbiformes"
species = "Raphus cucullatus" species = "Raphus cucullatus"
} }
extinct = true
} }
---- ----