# The new output of findfirst is dangerous

**URL:** <https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131>\
**Category:** General Usage\
**Created:** [February 17, 2018, 5:03pm UTC](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131 "2018-02-17T17:03:21Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![wherrera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wherrera/32/5288_2.png) [@wherrera](https://discourse.julialang.org/u/wherrera)\
**Post date:** [February 24, 2018, 2:35am UTC](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131/21 "2018-02-24T02:35:02Z")

</div>

I am using this wrapper, ie, use nothing2zero(findfirst()) instead of first(findfirst()):

“”" for julia version 0.7+ compatibility with findfirst() usage in a base-1 vector indexed v0.6 module “”"  
nothing2zero(x) = (typeof(x) == Void && x == nothing) ? 0 : x

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [February 24, 2018, 9:05pm UTC](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131/22 "2018-02-24T21:05:08Z")

</div>

You can use `coalesce(x, 0)` instead of defining your custom `nothing2zero` function. Compat provides it, and the deprecation message will recommend it [soon](https://github.com/JuliaLang/julia/pull/26149/).

[Previous page](https://discourse.julialang.org/t/the-new-output-of-findfirst-is-dangerous/9131.md?page=1)
