0
从这个命令,我可以得到数组索引,但我可以使用该索引作为整数更改数组索引到整数红宝石代码
index=strInput.each_index.select{|i| strInput[i] == subInput}.map(&:to_i)
puts (index)
当在打印输出,它与如[15]
桶显示当我尝试使用索引直接像
puts scores[index]
它返回错误
`[]': can't convert Array into Integer (TypeError)
如何将索引转换为整数。
Ps。 strInput = {1,2,3,4,5}/subInput = {3}
这是work.Thank你。 – user3214044