A bunch of static extensions to make life easier.
Static methods
staticrandomElementExcept<T>(array:Array<T>, except:T, unsafe:Bool = false):T
Return a random element contained in the given array that is not equal to the except
arg.
Parameters:
array | The array in which we extract the element from |
---|---|
except | The element we don't want |
unsafe | If set to |
Returns:
The random element or null
if nothing was found
staticrandomElementMatchingValidator<T>(array:Array<T>, validator:T ‑> Bool):T
Return a random element contained in the given array that is validated by the provided validator. If no item is valid, returns null.
Parameters:
array | The array in which we extract the element from |
---|---|
validator | A function that returns true if the item is valid, false if not |
Returns:
The random element or null
if nothing was found
staticshuffle<T>(arr:Array<T>):Void
Shuffle an Array. This operation affects the array in place. The shuffle algorithm used is a variation of the Fisher Yates Shuffle