Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

How to Find the First Instance of a Value in an Array

$
0
0

Hi all,

I was wondering why this wasn’t working:

mylist = ["a", "b", "c"]
findfirst(["a"], mylist)

As I expected it to work in at least Julia 1.6. Instead I got a stacktrace that looked like this:

ERROR: MethodError: no method matching findfirst(::Vector{String}, ::Vector{String})
Closest candidates are:
  findfirst(::Function, ::Union{AbstractString, AbstractArray}) at array.jl:1906
  findfirst(::Function, ::Any) at array.jl:1898
  findfirst(::AbstractArray) at array.jl:1824
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[22]:1

~ tcp :deciduous_tree:

5 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles