This commit is contained in:
krahets
2024-04-03 21:48:54 +08:00
parent d5a7899137
commit 0a9daa8b9f
11 changed files with 685 additions and 97 deletions

View File

@ -314,7 +314,7 @@ comments: true
### 随机访问元素 ###
def random_access(nums)
# 在区间 [0, nums.length) 中随机抽取一个数字
random_index = Random.rand 0...(nums.length - 1)
random_index = Random.rand(0...nums.length)
# 获取并返回随机元素
nums[random_index]