Basically, I want to have my own array-like class with my own methods.
I would like to initialize it by passing an arguement of the length of an array, and it should instantiate a new array with given length and filled with zeros. So I've written something like this:
class Foo < Array
def initialize(length)
Array.new(length, 0)
end
end
But when I test this out in IRB i get this:
a = Foo.new(5)
=> []
I also tried using for-loop to fill this array with zeros n-times, but to no avail.
What am I doing wrong?