-3
mir helfen, mit diesem Code T_T, warum es zeigen Syntaxfehler halten, unerwartet ':' exepcting End-of-Eingabe Datenbank: {Syntaxfehler, unerwartete ':' erwartet End-of-Eingang
database: { total_car_price: 20000, stock_car_price: 20000, features: { rim: { '16' => 50, '15' => 30, '14' => 10 }, color: { 'blue' => 0, 'red' => 0, 'yellow' => 0 }, tint: { '100' => 80, '80' => 50, '50' => 0 }, seat: { 'leather' => 500, 'PVC' => 300 } } } puts "Original price : #{database[:stock_car_price]}" database[:features].each do |feature, data| puts feature.upcase data.each do |option, extra_cost| puts "#{option} :: #{extra_cost}" end while true selection = gets.chomp if data.keys.include? selection #make it general that can accept string/integer database[:total_car_price] += data[selection] break else puts 'Incorrect selection!' end end end puts "Stock Price :: #{database[:stock_car_price]}" puts "Final Price :: #{database[:total_car_price]}"
Bitte formatieren Sie Ihren Code richtig. –
versuchen Sie 'ruby -w', um einen Hinweis darauf zu bekommen, wo der Fehler auftritt. –
Haben Sie meine Antwort unten versucht? – araratan