Material Box

Material Box

WEB Design & Material Images

Godot - Count occurrences of value in array

Godot

GDScript code example to count occurrences of specified value in array.


Can get count of occurrences of specified value in array using count() in GDScript.
Returns "0" if specified value does not exist.

var array = ["apple", "lemon", "apple", "banana"]
var count = array.count("apple")

print(count)
# 2

Godot

TitleGodot - Count occurrences of value in array

CategoryGodot

Created

Update

AuthorYousuke.U