Hello, sorry for this probably easy question but i can’t find the solution.
I add some Principals in a Buffer and I would like to remove duplicates Principals… There is many way to do, but Buffer methods always need the equal : (X, X) parameter… And I don’t know what is that and I didn’t easily find examples.
let buff : Buffer.Buffer<Principal> = Buffer.Buffer(10);
[...]
let principal1 = "xxxx-xxxx-..."
let principal2 = "xxxx-xxxx-..."
if( Buffer.contains(buff, principal1, ???) == false) // check if the principal is in the buffer
{
buff.add(principal1); //add if it's not
}
Thank you for this answer. This is was I tried to use : Principal.equal, as I used it to instanciate my Hashmaps, so, the problem is not from there…
Ok, I found immediately so, I had just forget to put var x = before my method : var x = Buffer.contains(buff, q2.answers[i].principal, Principal.equal);
Thank you also for the explanation about Set, it seems to be what I was looking for !