gpt4 book ai didi

ruby - 如何巧妙地进行数组加法?

转载 作者:太空宇宙 更新时间:2023-11-03 17:58:42 24 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How to sum array members in Ruby?

假设我有这个数组

@test = [1, 2, 3, 4]

然后我想做:

@test[0] + @test[1] + @test[2] + @test[3]

难道没有更智能、更快速的方法吗?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com