Erase not removing item in array that has says exists

Godot Version

v4.2.2.stable.official [15073afe3]

Question

I have a function that removes items in an array. For the most part, when I present a value to the erase function if it is in the array it removes. However when I pass it the name of a node, it doesn’t even though has() says the array has the item

func remove_needed(item):
	print ("erase: " ,item)
	print (needed_inputs.has(item))
	needed_inputs.erase(item)
	print ( needed_inputs)

Returns

erase: Strength
true
["Archetype", "Strength", "Dexterity", "Aptitude", "Fortitude", "Wits", "Will", "floating"]

It sees the value Strength, but it doesn’t remove it from the array for some reason

It is called in the node’s script by

CharacterSheet.remove_needed(self.name)

Any idea why it is not erasing the item, even though the has function says it is in the array?

I don’t know at all. Do you check if input “item” is a string?

Other possible solve, too more efficient, is doing a .find() to return the index, and erase it with .remove_at()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.