I have a new requirement on Array object. So I need to add my own method to built-in Array class.
How do I add a new method so that whatever Array object I create, it will also have my instance method?
I have a new requirement on Array object. So I need to add my own method to built-in Array class.
How do I add a new method so that whatever Array object I create, it will also have my instance method?
Use Ruby Open Classes:
class Array
def mymethod
#implementation
end
end
Array class, with all build in Array methods.