# When using Vector{T}(undef,n) constructor, what are the values set to?

**URL:** https://discourse.julialang.org/t/when-using-vector-t-undef-n-constructor-what-are-the-values-set-to/75251
**Category:** General Usage
**Created:** [January 26, 2022, 7:40pm UTC](https://discourse.julialang.org/t/when-using-vector-t-undef-n-constructor-what-are-the-values-set-to/75251 "2022-01-26T19:40:29Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)
#### Post date: [January 26, 2022, 7:45pm UTC](https://discourse.julialang.org/t/when-using-vector-t-undef-n-constructor-what-are-the-values-set-to/75251/2 "2022-01-26T19:45:07Z")

</div>

The values you get are whatever is in memory. They are actually not set to anything at all, so the values are completely _undefined_.

If you want your data initialized to `0`, then use `zeros`. For other values, use `fill!`.

See also [Faster zeros with calloc](https://discourse.julialang.org/t/faster-zeros-with-calloc/69860)

---

_[View the full topic](https://discourse.julialang.org/t/when-using-vector-t-undef-n-constructor-what-are-the-values-set-to/75251)._
