# Base.Show - unable to print using custom print

**URL:** https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575
**Category:** New to Julia
**Tags:** question
**Created:** [May 7, 2017, 12:47pm UTC](https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575 "2017-05-07T12:47:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Saran](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Saran](https://discourse.julialang.org/u/Saran)
#### Post date: [May 7, 2017, 12:47pm UTC](https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575/1 "2017-05-07T12:47:08Z")

</div>

I am declaring a custom type as Vector2Dim and i want to output to be printed with just the coordinates instead of Vector2Dim(x,y).  
However the same code if i execute in julia console it prints the desired output as [x,y] and if i write the code in a file  
and execute, it prints the output as Vector2Dim(x,y).  
Kindly let me know what changes do i need to make it to get the correct output. Below is the code and its output.

**Julia Version 0.5.1**  
**IDE: atom(juno)**

Code::

```julia
import Base.show

type Vector2Dim
  x::Float64
  y::Float64
end

a = Vector2Dim(3,4)

println(a)

show(io::IO, v::Vector2Dim) = print(io, "[$(v.x),$(v.y)]")

println(a)

```

Output::

```julia
Vector2Dim(3.0,4.0)
Vector2Dim(3.0,4.0)

```

**The required output is [3.0, 4.0]**

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [May 7, 2017, 12:53pm UTC](https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575/2 "2017-05-07T12:53:56Z")

</div>

This is the infamous [#265](https://github.com/julialang/julia/issues/265) Fixed on 0.6/master.

---

<div class="post-metadata">

### Author: ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)
#### Post date: [May 7, 2017, 1:10pm UTC](https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575/3 "2017-05-07T13:10:32Z")

</div>

if you don’t print before defining the custom `show` method it should work fine on 0.5

try

```julia
import Base.show

type Vector2Dim
  x::Float64
  y::Float64
end

show(io::IO, v::Vector2Dim) = print(io, "[$(v.x),$(v.y)]")

a = Vector2Dim(3,4)

println(a)

```

---

<div class="post-metadata">

### Author: ![Saran](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Saran](https://discourse.julialang.org/u/Saran)
#### Post date: [May 7, 2017, 2:03pm UTC](https://discourse.julialang.org/t/base-show-unable-to-print-using-custom-print/3575/4 "2017-05-07T14:03:35Z")

</div>

Thank you very much
