godotengine / godotengine/godot-docs

Array functions & type checks

Open
#5,189 3 comments 0 reactions 0 assignees View on GitHub
area:class reference bug
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:** v3.3.3

**Issue description:** Documentation incorrectly claims array.has is equivalent to using the 'in' operator

**URL to the documentation page:** https://docs.godotengine.org/en/stable/classes/class_array.html#class-array-method-has

I was thrown for a loop a bit when I tried to use the array.has(x) & array.erase(x) functions and while array.has(x) didn't work, 'x in array' did.
It turns out 'has' & 'erase' (and presumably other array functions) perform type checks before comparing, while the 'in' operator compares values ignoring variable types, in my case this means I was comparing floats & ints without knowing it would cause an issue because their values were equivalent(I was drawing numbers out of Vector2s, that's where the floats came from).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.