From 26ec8320d2c0013013e1c45e44c88d9781a67270 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 19 Apr 2024 01:54:25 +0200 Subject: [PATCH] Have `Random.sample` return null when the given array is empty --- random.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/random.gd b/random.gd index a0a37a0..2e9b2cb 100644 --- a/random.gd +++ b/random.gd @@ -13,6 +13,8 @@ static var rng: RandomNumberGenerator = null: static func sample(array: Array[Variant], imin = null, imax = null) -> Variant: + if len(array) == 0: + return null if imin == null: imin = 0 if imax == null: