But Mathew,
I've a doubt,Set doesn't allows duplicates so the duplicate won't be added,it will be discarded rather,so when we remove i1,output is 1 that's fine and when we remove i2 as well,shouldn't the output be 0 in-spite of 1?
Matthew Brown wrote:What would you expect the output to be?
You add two numbers. You add a duplicate, but this is a Set, so it doesn't allow duplicates. You remove one of them. You then try to remove a different value, so that has no effect.