我的代码看起来像这样
#!/usr/bin/ruby
Shas = ["Pesachim","Shekalim","Yoma"]
Pesachim=["2a", "2b", "3a", "3b", "4a", "4b", "5a", "5b", "6a", "6b", "7a", "7b"]
Shekalim=["2a", "2b", "3a", "3b", "4a", "4b", "5a", "5b", "6a", "6b", "7a"]
Yoma=["2a", "2b", "3a", "3b", "4a", "4b", "5a", "5b", "6a", "6b", "7a", "7b", "8a", "8b", "9a", "9b", "10a", "10b", "11a", "11b", "12a", "12b", "13a", "13b", "14a"]
counter = 0
while counter < Pesachim.length
puts Shas[0] +" "+ Pesachim[counter]
counter +=1
bounter = 0
while bounter < Shekalim.length
puts Shas[1] +" "+ Shekalim[bounter]
bounter +=1
你能帮我把它改写成
Shas.each do |book|
counter = 0
while counter < book.length
puts book+" "+book[counter]
counter+=1
end
我认为“书籍”与没有双引号的数组不同存在一些问题。