Error: findfirst(((x,y))->x==1, [(1,2), (3,4)])

Note that this is the same problem as:

julia> f = ((x,y)) -> x == 1
#20 (generic function with 1 method)

julia> f((1,1))
ERROR: MethodError: no method matching (::var"#20#21")(::Tuple{Int64, Int64})
Closest candidates are:
  (::var"#20#21")(::Any, ::Any) at REPL[17]:1
Stacktrace:
 [1] top-level scope
   @ REPL[18]:1

julia> f(1,1)
true

seems to be a parsing edge case.

You can solve that by adding a comma:

julia> findfirst( ((x,y),) -> x == 1 , [(1,2), (3,4)])
1

2 Likes