The Toggle function adds an index item to the set if the set doesn't have it and otherwise, the function removes the item. It is the same as s[index] = !s[index]. The function returns the previous state - true if the item existed and, otherwise, false.