# Error printing custom types

**URL:** https://discourse.julialang.org/t/error-printing-custom-types/33414
**Category:** Juno
**Tags:** bug, repl
**Created:** [January 15, 2020, 8:45pm UTC](https://discourse.julialang.org/t/error-printing-custom-types/33414 "2020-01-15T20:45:37Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![RodolfoFigueroa](https://avatars.discourse-cdn.com/v4/letter/r/a9a28c/32.png) [@RodolfoFigueroa](https://discourse.julialang.org/u/RodolfoFigueroa)
#### Post date: [January 15, 2020, 8:45pm UTC](https://discourse.julialang.org/t/error-printing-custom-types/33414/1 "2020-01-15T20:45:37Z")

</div>

If we define a new `show` method for a custom class and then create a variable with said class, Juno will keep printing the variable to the REPL. Here is a MWE:

```julia
import Base.show
mutable struct foo
    bar
end
function show(io::IO, a::foo)
    print(a.bar)
    return
end
t = foo(1)

```

If we run this, it will print `11` to the REPL (which is already wrong, since it’s showing `t` twice). Furthermore, all following REPL prompts will show `julia>1`.

This does not happen if we execute the code directly from the REPL.

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [January 15, 2020, 9:01pm UTC](https://discourse.julialang.org/t/error-printing-custom-types/33414/2 "2020-01-15T21:01:39Z")

</div>

That’s happening because your definition of `show` is wrong. You’re printing to `stdout` instead of `io`, so whenever `show` is called you’ll see a `1` pop up in the REPL. When Juno shows your variable in the Workspace `show` is called, just like when displaying a result in the REPL – you’ll end up seeing `11`.

Basically, your code works in the REPL only by accident, because usually `io == stdout` in that case.
