【发布时间】:2026-01-19 15:50:02
【问题描述】:
这里是列表:
[ [ "First", "A" ], [ "Second", "B" ] ]
我现在正在使用:
"#{list[0]} is the first element"
返回:
"firsta is the first element"
我希望它返回:
["First", "A"] is the first element
完整代码:
set1 = list[0].last.downcase
set2 = list[1].last.downcase
if set1.eql?(set2)
"#{list[0]} is the first element"
elseif
#to-do
else
#to-do
end
另外,我正在使用来自 labs.codecademy.com (Ruby 1.8.7) 的在线解释器。
【问题讨论】:
-
你能发布完整的程序代码吗?我正在 IRB 中尝试这个,它给了我想要的结果,我不确定你是如何看待“firsta 是第一个元素”。
-
我想他正在使用 ruby 1.8
标签: ruby-on-rails ruby arrays multidimensional-array