# Re: Quickie: Monkey patching Array

**URL:** <https://www.ruby-forum.com/t/re-quickie-monkey-patching-array/139082>\
**Category:** Ruby\
**Created:** [May 30, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/re-quickie-monkey-patching-array/139082 "2008-05-30T17:14:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![reidmix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19b73/32.png) [@reidmix](https://www.ruby-forum.com/u/reidmix)\
**Post date:** [May 30, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/re-quickie-monkey-patching-array/139082/1 "2008-05-30T17:14:50Z")

</div>

you are just assigning a to an array literal  
This is equivalent to  
a = Array.new([‘one’,‘two’,‘three’])  
Like Siep said, array access a[0] will raise the error.  
r

----- Original Message ----  
From: Siep K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Thursday, May 29, 2008 3:28:45 PM  
Subject: Re: Quickie: Monkey patching Array

Leon B. wrote:

> Didn’t work also. It just prints: [“one”, “two”, “three”]

try

p a[0]

[] is just a method. You chanced it. To verify if your change works, you  
'll have to use the [] method. If this is not what you want, what  
outcome did you expect?

regards,

Siep
