W
wroxdb
Hello,
what's the argument of "obj" in: def []=(index,obj) ?
I don't see it call this method with the second argument.
Thanks
The original code is:
class Array2 < Array
def [](index)
if index>0
super(index-1)
else
raise IndexError
end
end
def []=(index,obj)
if index>0
super(index-1,obj)
else
raise IndexError
end
end
end
x = Array2.new
x[1]=5
x[2]=3
x[0]=1 # Error
x[-1]=1 # Error
what's the argument of "obj" in: def []=(index,obj) ?
I don't see it call this method with the second argument.
Thanks
The original code is:
class Array2 < Array
def [](index)
if index>0
super(index-1)
else
raise IndexError
end
end
def []=(index,obj)
if index>0
super(index-1,obj)
else
raise IndexError
end
end
end
x = Array2.new
x[1]=5
x[2]=3
x[0]=1 # Error
x[-1]=1 # Error