gpt4 book ai didi

ruby-on-rails - 在数组的前 X 个元素上调用 .map

转载 作者:数据小太阳 更新时间:2023-10-29 06:58:57 25 4
gpt4 key购买 nike

我只想对数组的前 X 个元素调用 .map。我该怎么做?

最佳答案

在 ruby 1.9 中

array.first(X).map{|e| ...}

在 ruby 1.8 中

array[0, X].map{|e| ...}

关于ruby-on-rails - 在数组的前 X 个元素上调用 .map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5932332/

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