我一直試圖在過去教自己Ruby,而我一直試圖得到類似下面的東西,但我得到以下錯誤......
file.rb:44:in
func': undefined local variable or
method number' # (NameError)
The code that's giving me this error is...
class A
def func
file = File.new("file", "r")
file.each_line {|line| @numbers << line.chomp.to_i}
@number = @array[0]
end
end
class B < A
def func
super number
puts number
end
end
Could someone please tell me what I'm doing wrong?
edit// Just a clarification that I want number in class
B
to inherit the value of @number
in
class A
.