# Show for vector type that defines matrix getindex

**URL:** <https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732>\
**Category:** General Usage\
**Created:** [May 1, 2019, 12:10pm UTC](https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732 "2019-05-01T12:10:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [May 1, 2019, 12:22pm UTC](https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732/2 "2019-05-01T12:22:03Z")

</div>

The basic problem here is that your `getindex(v::Vector{MyVec}, i::Int, j::Int)` breaks how vectors work. In order to let the same code work with either vectors or single-column matrices, arrays are treated as if they had an infinite number of trailing singleton dimensions:

```julia
julia> x = rand(3)
3-element Array{Float64,1}:
 0.5208526911072409 
 0.42943207563780583
 0.6718262282859668 

julia> x[2,1]
0.42943207563780583

julia> x[2,1,1]
0.42943207563780583

julia> [size(x,i) for i = 1:3]
3-element Array{Int64,1}:
 3
 1
 1

```

---

_[View the full topic](https://discourse.julialang.org/t/show-for-vector-type-that-defines-matrix-getindex/23732)._
