Skip to content

Commit

Permalink
Fix GetRandomValue out of range (#2616)
Browse files Browse the repository at this point in the history
  • Loading branch information
IkaOverride authored Jun 9, 2024
1 parent 7a2eb2f commit 8891696
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Exiled.API/Extensions/CommonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class CommonExtensions
/// <param name="enumerable"><see cref="IEnumerable{T}"/> to be used to get a random value.</param>
/// <typeparam name="T">Type of <see cref="IEnumerable{T}"/> elements.</typeparam>
/// <returns>Returns a random value from <see cref="IEnumerable{T}"/>.</returns>
public static T GetRandomValue<T>(this IEnumerable<T> enumerable) => enumerable is null || enumerable.Count() == 0 ? default : enumerable.ElementAt(Random.Range(0, enumerable.Count()));
public static T GetRandomValue<T>(this IEnumerable<T> enumerable) => enumerable is null || enumerable.Count() == 0 ? default : enumerable.ElementAt(Random.Range(0, enumerable.Count() - 1));

/// <summary>
/// Gets a random value from an <see cref="IEnumerable{T}"/> that matches the provided condition.
Expand Down Expand Up @@ -62,4 +62,4 @@ public static AnimationCurve Add(this AnimationCurve curve, float amount)
return curve;
}
}
}
}

0 comments on commit 8891696

Please sign in to comment.