# How to convert Vector{Any} to a narrower type?

**URL:** <https://discourse.julialang.org/t/how-to-convert-vector-any-to-a-narrower-type/60376>\
**Category:** General Usage\
**Created:** [May 1, 2021, 12:23pm UTC](https://discourse.julialang.org/t/how-to-convert-vector-any-to-a-narrower-type/60376 "2021-05-01T12:23:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [May 1, 2021, 12:29pm UTC](https://discourse.julialang.org/t/how-to-convert-vector-any-to-a-narrower-type/60376/2 "2021-05-01T12:29:57Z")

</div>

You can broadcast identity.

> [@Is there a coalesce function for other types?](https://discourse.julialang.org/t/is-there-a-coalesce-function-for-other-types/60112):
>
> I found this nice function called coalesce and now I am wondering if there is a more general one. Is there a function like coalesce which can specify the missing value/type. a = [NaN,missing,"",2,3.0] coalesce.(a,0) coalesce.(a,0,missing="") # fails coalesce.(a,0,missing=NaN) # fails Update: A good solution might be: clean(a,junk,target) = identity.(replace(a, (junk .=\> target)...)) clean(a,["",missing,NaN],0)

---

_[View the full topic](https://discourse.julialang.org/t/how-to-convert-vector-any-to-a-narrower-type/60376)._
