-1
这里是清单:如何从两个元素列表中打印出一个元素,同时保留括号和引号?
[ [ "First", "A" ], [ "Second", "B" ] ]
现在我使用:
"#{list[0]} is the first element"
将返回:
"firsta is the first element"
我想它返回:
["First", "A"] is the first element
Full code:
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是第一个元素”。 – 2012-03-03 19:56:07
他使用红宝石1.8我想 – fl00r 2012-03-03 20:01:39