Finding indices using "setdiff"?

Hey guys, say I have these two arrays:

A = ["1" "2" "3" "4"];
B = ["1" "2" "3" "4" "5" "6"];

Then I can use “setdiff” to find the elements which they do not have in common as such:

C = setdiff(B,A)
2-element Array{String,1}:

My question is then, would it be possible to get the indices instead? Note the example is string based.

Kind regards

One obvious way would be

[findfirst(isequal(x), B) for x in setdiff(B,A)]

By the way, do you deliberately work with 1xN matrices instead of column vectors (A = ["1", "2", "3", "4"];) ? Typically, the latter is preferable.

1 Like

Thanks! It was just an example, usually I also work with column vectors.

Kind regards