Created
September 3, 2025 19:38
-
-
Save cosinewaves/b747178c668b2f37821d6205060d569d to your computer and use it in GitHub Desktop.
returns a random element in table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --!strict | |
| -- pick.luau | |
| math.randomseed(os.clock()) | |
| return function<T>(list: { T }): T | |
| assert(#list > 0, "tried to pick a element from an empty table") | |
| return list[math.random(1, #list)] :: T | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment