Solved, was pretty simple in the end:
if(set array[index] = newelement){}
the curly brackets at the end are necessary