我开始学习Ruby,当我在终端上运行代码时遇到了一些问题。它说 :
desktop/RUBY/boucles.rb: line 1: voyages: command not found
desktop/RUBY/boucles.rb: line 14: syntax error: unexpected end of file.
我的ID是崇高的文字。
我怎么解决这个问题?
voyages = [
{ ville: "Paris", duree: 10 },
{ ville: "New York", duree: 5 },
{ ville: "Berlin", duree: 2 },
{ ville: "Montreal", duree: 15 }
]
voyages.each do |voyage|
if voyage[:duree] <= 5
puts "Voyage à #{voyage[:ville]} de #{voyage[:duree]} jours"
end
end