Commit fa8e6b9ba1babc8d971107f2540b6385786bc8ca

Jeremy JEANNE 2025-04-01T12:36:44

Tuple type

diff --git a/doc/1_KC3/1.22_Tuple.en.md b/doc/1_KC3/1.22_Tuple.en.md
new file mode 100644
index 0000000..59627d8
--- /dev/null
+++ b/doc/1_KC3/1.22_Tuple.en.md
@@ -0,0 +1,66 @@
+# 1.21 Map
+
+KC3 maps are like Elixir maps, they are key-values enclosed in `%{}` :
+
+```elixir
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1,
+  title: "My title",
+  message: "Hello, world !"}
+```
+
+Destructuring works with maps to extract values :
+
+```elixir
+ikc3> %{id: id, title: "My title", message: message} = ^ a
+%{id: 1,
+  title: "My title",
+  message: "Hello, world !"}
+ikc3> id
+1
+ikc3> message
+"Hello, world !"
+```
+
+
+You can use the dot syntax to access map values from a `Sym` key :
+
+```elixir
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1,
+  title: "My title",
+  message: "Hello, world !"}
+ikc3> a.id
+1
+ikc3> a.message
+"Hello, world !"
+```
+
+You can also use the `KC3.access` function for the same result :
+
+```elixir
+ikc3> a = %{id: 1, title: "My title", message: "Hello, world !"}
+%{id: 1,
+  title: "My title",
+  message: "Hello, world !"}
+ikc3> access(a, :id)
+1
+ikc3> access(a, :message)
+"Hello, world !"
+```
+
+To update an existing map you can use Map.put like this :
+
+```elixir
+ikc3> a = %{id: 1, title: "My title"}
+%{id: 1,
+  title: "My title"}
+ikc3> a = Map.put(a, :message, "Hello, world !")
+%{id: 1,
+  title: "My title",
+  message: "Hello, world !"}
+```
+
+---
+
+Top : [KC3 documentation](/doc/)