error:C:\Users\RR\Desktop\ruby_sandbox>ruby classes.rb classes.rb:44: syntax error, unexpected end-of-input, expecting keyword_end我無法執行該程序
我的代碼是:
class Animal
attr_accessor :name,:age,:sex,:location
def initialize(age=18,sex="not available",location="not specified")
puts "details of animal"
@age=age
@sex=sex
@location=location
end
def condition(age,name)
if animal.age>animal1.age
puts "#{animal.name } is older than #{animal1.name}"
else
puts "animals age are in increasing order"
end
end
你應該在末尾加上'end' – Ilya
謝謝你的幫助..我檢查一下.. – pHorekka
同樣值得注意的是'animal1'是你指的東西,但從來沒有被定義在任何地方。 – tadman