Not gonna lie, I was looking at going in that direction if I needed to, but, I am much more comfortable with what @gertkeno did. I now have it working with what he did.
If you want to go really effecient, you can notice that an array of bool is the same as a binary number
1001 vs true, false, false, true
bitwise operators let you use ints as bool arrays, and so does @export_flags. this lets you create properties in the inspector like collision layer/mask where you can select multiple true/false values.
@export_flags("Fire", "Water", "Earth", "Wind") var spell_elements = 0
func has_water() -> bool:
# binary is flipped compared to the flag names
return spell_elements & 0b0010 != 0
func has_wind() -> bool:
return spell_elements & 0b1000 != 0
Something to try out, if your use case can leverage it.