How to check if two arrays share a (or any) value - GDSCRIPT

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By JayJay99

I’m know it’s a pretty trivial task, I’m know I can make a function of it, I just wanna know if GDSCRIPT already has a native one line approach for it.

for python I found this: Test if lists share any items in python - Stack Overflow

:bust_in_silhouette: Reply From: lewis glasgow
array1 = []
array2 = []

func _process(delta):
	for i in array1:
		for o in array2:
			if i == o:
				print("yes")

Remember to break after one match was found, so that the CPU doesn’t waste time comparing elements after one set of elements was found to be matching.

Calinou | 2021-08-02 22:14