class Fixnum
def repeat
for i in 1..self.to_i
yield
end
end
end
z = Fixnum.new 4
The program above is giving undefined method new for Fixnum:Class (NoMethodError). Why so? I just tried using it in another class and it works.
Thanks!
It looks to me that the method and the error have no relation, why are you doing z = Fixnum.new 4?
The method should be used like: