# Write function "show" for own multi-level structure

**URL:** <https://discourse.julialang.org/t/write-function-show-for-own-multi-level-structure/81882>\
**Category:** Visualization\
**Tags:** show\
**Created:** [May 29, 2022, 7:09pm UTC](https://discourse.julialang.org/t/write-function-show-for-own-multi-level-structure/81882 "2022-05-29T19:09:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuri](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@Yuri](https://discourse.julialang.org/u/Yuri)\
**Post date:** [May 29, 2022, 7:09pm UTC](https://discourse.julialang.org/t/write-function-show-for-own-multi-level-structure/81882/1 "2022-05-29T19:09:14Z")

</div>

I want to write a function `Base.show` for my structure `Node`:

```julia
mutable struct Node
    keys::Vector
    vals::Vector
    count::Int
end

```

and which will display:

```julia
nod = Node(
    ["a", "b", "c", "d"],
    [Node( 
        ["aA", "aB", "aC"], 
        [11, 12, 13], 
        3,
    ), 2, 3, 4],
    4
)

```

as well as display `OrderedDict` the following dict:

```julia
dict_ord = OrderedDict(
    "a" => OrderedDict(
        "aA" => 11,
        "aB" => 12,
        "aC" => 13,
    ),
    "b" => 2,
    "c" => 3,  
    "d" => 4,
)

```

 ![Снимок экрана 2022-05-29 в 22.08.31](https://global.discourse-cdn.com/julialang/original/3X/b/4/b4e13cf735f3aba0fd62506bcb763604844a04fa.png)

---

<div class="post-metadata">

**Author:** ![lostella](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lostella/32/356_2.png) [@lostella](https://discourse.julialang.org/u/lostella)\
**Post date:** [May 29, 2022, 7:19pm UTC](https://discourse.julialang.org/t/write-function-show-for-own-multi-level-structure/81882/2 "2022-05-29T19:19:04Z")

</div>

Besides doing it yourself, you could also consider using existing packages for pretty-printing nested structures, see eg [GitHub - MechanicalRabbit/PrettyPrinting.jl: Julia library for optimal formatting of composite data structures](https://github.com/MechanicalRabbit/PrettyPrinting.jl)

---

<div class="post-metadata">

**Author:** ![Yuri](https://avatars.discourse-cdn.com/v4/letter/y/71c47a/32.png) [@Yuri](https://discourse.julialang.org/u/Yuri)\
**Post date:** [May 29, 2022, 7:35pm UTC](https://discourse.julialang.org/t/write-function-show-for-own-multi-level-structure/81882/3 "2022-05-29T19:35:47Z")

</div>

I would like to write my own function so that Atom displays the result near the code, and not in the console, and so that there is a visual disclosure/hiding of nested structures (as in the photo in the description)
