Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool{Type}Array has no method 'has' #41075

Closed
toby3d opened this issue Aug 6, 2020 · 2 comments
Closed

Pool{Type}Array has no method 'has' #41075

toby3d opened this issue Aug 6, 2020 · 2 comments

Comments

@toby3d
Copy link
Contributor

toby3d commented Aug 6, 2020

Godot version: 3.2.3.rc1
OS/device including version: Linux 5.7.9-1-MANJARO
Issue description: Unlike Array, PoolStringArray, PoolIntArray and others doesn't have a method to check if an element is present.

Steps to reproduce / Minimal reproduction project:

var _array: Array = ['a', 'b', 'c']
_array.has('b') # true
_array.has('z') # false
var _array: PoolStringArray = ['a', 'b', 'c']
_array.has('b') # The method "has" isn't declared on base "PoolStringArray"

There are two workarounds to solve this:

var _array: PoolStringArray = ['a', 'b', 'c']
(_array as Array).has('b') # true
(_array as Array).has('z') # false
static func has_string(src: PoolStringArray, find: String) -> bool:
	for item in src:
		if item != find:
			continue
		
		return true

	return false

...

var _array: PoolStringArray = ['a', 'b', 'c']
has_string(_array, 'b') # true
has_string(_array, 'z') # false
@toby3d toby3d changed the title PoolStringArray has no method 'has' Pool{Type}Array has no method 'has' Aug 6, 2020
@Calinou
Copy link
Member

Calinou commented Aug 6, 2020

This was implemented by #32144, but I'm not sure if it's worth remaking for the 3.2 branch.

@pouleyKetchoupp pouleyKetchoupp added this to the 3.2 milestone Aug 7, 2020
@aaronfranke aaronfranke modified the milestones: 3.2, 3.3 Mar 16, 2021
@aaronfranke aaronfranke modified the milestones: 3.3, 3.4 Apr 21, 2021
@akien-mga akien-mga modified the milestones: 3.4, 3.5 Nov 8, 2021
@timothyqiu
Copy link
Member

Fixed by #60856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants