# Implement show function to make inline result display correctly

**URL:** <https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602>\
**Category:** VS Code\
**Created:** [September 21, 2022, 8:56pm UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602 "2022-09-21T20:56:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [September 21, 2022, 8:56pm UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/1 "2022-09-21T20:56:44Z")

</div>

I have a struct that wraps a `DataFrame`, Could I ask how to dispatch `Base.show` function to make it display correctly in hover results?

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/2/825689b122a965b1b514f01bfd2cb78eca523449.png)  
Currently, the hover result displays nothing.

---

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [September 21, 2022, 10:41pm UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/2 "2022-09-21T22:41:13Z")

</div>

You can try something like this:

```julia
struct Name
    table::DataFrame
end

Base.show(io::IO, n::Name) = print(io, "$(n.table)")

data = DataFrame()
nm = Name(data)

```

Which for me prints the same info as for a plain DataFrame.  
You can also go check code of packages on github to see more complex options.

---

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [September 22, 2022, 12:01am UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/3 "2022-09-22T00:01:08Z")

</div>

> [@mkoculak](#):
>
> ```julia
> struct Name
> table::DataFrame
> end
> 
> Base.show(io::IO, n::Name) = print(io, "$(n.table)")
> 
> data = DataFrame()
> nm = Name(data)
> 
> ```

Hi, thanks for your answer and it works!  
But do you know why calling `DataFrames.show(n.table, kwargs...)` (I want to customize it a bit) not working? Have been trying different thing for hours ☹

---

<div class="post-metadata">

**Author:** ![mkoculak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkoculak/32/28310_2.png) [@mkoculak](https://discourse.julialang.org/u/mkoculak)\
**Post date:** [September 22, 2022, 12:20am UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/4 "2022-09-22T00:20:04Z")

</div>

Are you thinking about [this version of show](https://dataframes.juliadata.org/stable/lib/functions/#Base.show) from the DataFrames package?

As you can see there, the documentation refers to `Base.show` because DataFrames.jl extends the function from base to their object. Therefore they do not export this method.  
Simply, you can use `show(DataFrame, kwargs...)` just as it is shown in the docs to achieve what you want.

---

<div class="post-metadata">

**Author:** ![Frankiewaang](https://avatars.discourse-cdn.com/v4/letter/f/f9ae1b/32.png) [@Frankiewaang](https://discourse.julialang.org/u/Frankiewaang)\
**Post date:** [September 22, 2022, 1:06am UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/5 "2022-09-22T01:06:16Z")

</div>

That’s really helpful!!! Learned some Julia tody 🙂  
I tweak your example and the result in the terminal is good but the inline result still failed. Do you have any suggestion?

Thank you so much again, I love this community so much!

```plaintext
struct Name
    table::DataFrame
end

Base.show(io::IO, n::Name) = show(n.table; show_row_number=false)

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/8/88c9b3c80e6eccd58d33c7e518d8b9bc59aaeb92.png)

---

<div class="post-metadata">

**Author:** ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)\
**Post date:** [September 22, 2022, 1:52am UTC](https://discourse.julialang.org/t/implement-show-function-to-make-inline-result-display-correctly/87602/6 "2022-09-22T01:52:56Z")

</div>

> [@Frankiewaang](#):
>
> `Base.show(io::IO, n::Name) = show(n.table; show_row_number=false)`

I think this should be

```julia
Base.show(io::IO, n::Name) = show(io, n.table; show_row_number=false)

```

but I don’t know whether that will fix your problem.
