The new output of findfirst is dangerous

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

You can use coalesce(x, 0) instead of defining your custom nothing2zero function. Compat provides it, and the deprecation message will recommend it soon.

1 Like