Monkey patching is a common practice in Ruby, but it can be problematic for a lasting application to override core aspects of the language. Renaming and inheriting core classes is a better approach.

class AlteredArray < Array
  def [](idx)
    self.fetch(idx)
  end
end

:) Happy Holidays!

Leave a Reply

Your email address will not be published. Required fields are marked *