# Can include method be used for multiple values in Ruby?

**URL:** <https://www.ruby-forum.com/t/can-include-method-be-used-for-multiple-values-in-ruby/259693>\
**Category:** Uncategorized\
**Created:** [June 1, 2020, 9:15am UTC](https://www.ruby-forum.com/t/can-include-method-be-used-for-multiple-values-in-ruby/259693 "2020-06-01T09:15:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danito](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/danito/32/2435_2.png) [@Danito](https://www.ruby-forum.com/u/Danito)\
**Post date:** [June 1, 2020, 9:15am UTC](https://www.ruby-forum.com/t/can-include-method-be-used-for-multiple-values-in-ruby/259693/1 "2020-06-01T09:15:46Z")

</div>

![include](https://www.ruby-forum.com/uploads/default/original/2X/f/fc2c552cfc6cc42a98a7d8b04c8190660313c8fe.png)

I have that snippet of Ruby code.  
$letters\_arr is an array of letters of a random word . The user will enter a letter for example “a” which will be assigned to user\_choice variable.  
Then the IF statement checks if that letter is included in $letters\_arr . If the letter was included once then it will be pushed to a new array with no problem and all works fine, but if the letter was included more than one time . The first time will cause no error but second time when the user enters the letter again will cause problem !

The thing i want to do is when the user enters the letter and i check if it is included . If it was included more than one time then the letter will be pushed to all locations that is included in all at once.

For example if the letter was “a” and it was included in $letters\_arr[0] , $letters\_arr[3] , $letters\_arr[5] then the push method push it in all of those indexes.

Is there a method for that ? or how i will be able to solve that problem ?

---

<div class="post-metadata">

**Author:** ![Maniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/13edae/32.png) [@Maniac](https://www.ruby-forum.com/u/Maniac)\
**Post date:** [December 20, 2020, 9:01pm UTC](https://www.ruby-forum.com/t/can-include-method-be-used-for-multiple-values-in-ruby/259693/2 "2020-12-20T21:01:07Z")

</div>

Hello @Danito,

If you still need help, would you please post the entire code here instead of showing a screenshot?
