Witam
Jak można sprawić, żeby metoda w klasie rozpoznawała tablicę zadeklarowaną w konstruktorze?
class MyClass
def initialize
arr = []
end
def my_func
arr.push(1)
puts arr.size
end
end
obj = MyClass.new
obj.my_func
undefined local variable or method 'arr' for #<MyClass:0x005577772b15a8> (NameError)