0
我的代碼不工作!它說,在終端下面對主新對象中的類錯誤
未定義局部變量或方法皮卡丘:對象 (NameError)
代碼:
class Pokemon
def initialize(type, name, attack, hp)
# Instance variables
@type = type
@name = name
@attack = attack
@hp = hp
end
def display
puts "This is #{@name} it is a #{@type} type and has #{@attack} attack and #{@hp} hp"
end
end
p = pikachu.new("eletric", "pikachu", "100", "200")
p.initialize
p.display`
被稱爲好,我不得不拿出p.initialize但在這之後的工作!謝謝btw – kopimopi