# Reshape of numbers. Is it a bad idea?

**URL:** https://discourse.julialang.org/t/reshape-of-numbers-is-it-a-bad-idea/37151
**Category:** General Usage
**Tags:** question
**Created:** [April 7, 2020, 8:45am UTC](https://discourse.julialang.org/t/reshape-of-numbers-is-it-a-bad-idea/37151 "2020-04-07T08:45:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [April 7, 2020, 8:45am UTC](https://discourse.julialang.org/t/reshape-of-numbers-is-it-a-bad-idea/37151/1 "2020-04-07T08:45:27Z")

</div>

I have a function when I want to be sure one parameter is a vector, even if it is given as number.

I thought to use `reshape(myInt,1)` but notice reshape of numbers is not in `Base`.  
No problem, I can add a method to handle it:

```julia
import Base.reshape
function reshape(x::Number, dims...) where {T <: Number}
   x = [x]
   reshape(x,dims)
end

```

But, as it is not in `Base`, I wonder if it is a good approach or it is intentionally left it out from `Base`.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [April 7, 2020, 9:13am UTC](https://discourse.julialang.org/t/reshape-of-numbers-is-it-a-bad-idea/37151/2 "2020-04-07T09:13:23Z")

</div>

I would just do something like

```julia
ensure_vector(v::AbstractVector) = v
ensure_vector(x::Number) = [x] # consider SVector(x), depending on context

```
