當我在Ruby中運行下面的代碼時,出現如下錯誤:ex5.rb:3:in '<main>': undefined local variable or method 'cm' for main:Object <NameError>
如何在Ruby中將磅轉換爲kg?
我在做什麼錯了?
name = 'Chris Hanson'
height = 60 * cm
cm = 2.54
weight = 180 % kg
kg = 2.2
eyes = 'Brown'
teeth = 'White'
hair = 'Black'
puts "Let's talk about #{name}."
puts "He's #{height} cm tall."
puts "He's #{weight} kg heavy."
puts "He's got #{eyes} eyes and #{hair} hair."
puts "His teeth are usually #{teeth} depending on the coffee."
非常感謝! – Ellen