Hi I want to loop a set of Strings and convert them from String type to ObjectId type.
I tried this way:
followingIds.foreach(e => e = new ObjectId(e))
But I cant do that assignement.
I also tried using “for” but I don’t know how to access each position of the Set by Index.
for (i <- 0 until following.size) {
following[i] = new ObjectId(following[i])
}
This neither work,
Can anyone help me?!? Please!
If you insist on mutability you can go with something like this:
But you can make your code more scalish with immutable things:
Now variables (values) names are pretty descriptive