I don’t think the example in the original post has the correct result – if I (and several other posters) understand correctly, the result should be b=[3.0,2.0].
Other people’s notes about arrays of tuples or struct arrays are probably the better solutions. But to answer the original question directly, this looks like a good candidate for logical indexing:
julia> a = [2.0 1.0; 3.0 0.0; 4.0 1.0; 2.0 0.0; 4.0 1.0]
5×2 Matrix{Float64}:
2.0 1.0
3.0 0.0
4.0 1.0
2.0 0.0
4.0 1.0
julia> b = a[@view(a[:, 2]) .== 0, 1] # the @view() is unnecessary but gives slightly better performance
2-element Vector{Float64}:
3.0
2.0
Some of the other suggested methods (the comprehensions in particular) might be marginally more efficient than this, however.