Edit

kc3-lang/kc3/doc/1_KC3/1.22_Tuple.en.md

Branch :

  • doc/1_KC3/1.22_Tuple.en.md
  • # 1.22 Tuple
    
    KC3 tuples are arrays of `Tag`.
    
    ## 1.22.1 Examples
    
    ```elixir
    ikc3> a = {:ok, "My title", "Hello, world !"}
    {:ok, "My title", "Hello, world !"}
    ```
    
    Destructuring works with tuples to extract values :
    
    ```elixir
    ikc3> {:ok, title, message} = ^ a
    {:ok, "My title", "Hello, world !"}
    ikc3> title
    "My title"
    ikc3> message
    "Hello, world !"
    ```
    
    You can also use the `KC3.access` function for the same result :
    
    ```elixir
    ikc3> a = {:ok, "My title", "Hello, world !"}
    {:ok, "My title", "Hello, world !"}
    ikc3> access(a, 0)
    :ok
    ikc3> access(a, 1)
    "My title"
    ikc3> access(a, 2)
    "Hello, world !"
    ```
    
    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 !"
    ```