# Remove element from array

**URL:** <https://www.ruby-forum.com/t/remove-element-from-array/85221>\
**Category:** Ruby\
**Created:** [February 11, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/remove-element-from-array/85221 "2007-02-11T17:42:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 11, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/remove-element-from-array/85221/1 "2007-02-11T17:42:36Z")

</div>

Hi,  
how can I do to rtemove an elemnt from an array,

I have this array :  
“user”=\>{“password\_confirmation”=\>"", “screen\_name”=\>“sdfsdfsdfsdf”,  
“first\_name”=\>“sdfsdfsd”, “last\_name”=\>“dskkd”, “password”=\>"",  
“email”=\>“removed\_email\_address@domain.invalid”}

And I want to remove the elements “password\_confirmation” and  
“password”.

How should I do this. I found nothing in docs, setting them to nil it’s  
not an option

thanks

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 11, 2007, 5:45pm UTC](https://www.ruby-forum.com/t/remove-element-from-array/85221/2 "2007-02-11T17:45:42Z")

</div>

J. mp wrote:

> Hi,  
> how can I do to rtemove an elemnt from an array,
> 
> I have this array :  
> “user”=\>{“password\_confirmation”=\>"", “screen\_name”=\>“sdfsdfsdfsdf”,  
> “first\_name”=\>“sdfsdfsd”, “last\_name”=\>“dskkd”, “password”=\>"",  
> “email”=\>“removed\_email\_address@domain.invalid”}
> 
> And I want to remove the elements “password\_confirmation” and  
> “password”.
> 
> How should I do this. I found nothing in docs, setting them to nil it’s  
> not an option
> 
> thanks

sorry for making loosing your time. I’m a looser 🙂  
it’s from an Hash and not from and array

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 11, 2007, 5:52pm UTC](https://www.ruby-forum.com/t/remove-element-from-array/85221/3 "2007-02-11T17:52:30Z")

</div>

Hi –

On Mon, 12 Feb 2007, J. mp wrote:

> > “password”.
> > 
> > How should I do this. I found nothing in docs, setting them to nil it’s  
> > not an option
> > 
> > thanks
> 
> sorry for making loosing your time. I’m a looser 🙂  
> it’s from an Hash and not from and array

See the docs for Hash#delete, Hash#delete\_if, and Hash#reject! (That  
exclamation point is part of the method name.)

David

---

<div class="post-metadata">

**Author:** ![j-merrill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/aeb1de/32.png) [@j-merrill](https://www.ruby-forum.com/u/j-merrill)\
**Post date:** [February 11, 2007, 5:58pm UTC](https://www.ruby-forum.com/t/remove-element-from-array/85221/4 "2007-02-11T17:58:46Z")

</div>

unknown wrote:

> Hi –
> 
> On Mon, 12 Feb 2007, J. mp wrote:
> 
> > > “password”.
> > > 
> > > How should I do this. I found nothing in docs, setting them to nil it’s  
> > > not an option
> > > 
> > > thanks
> > 
> > sorry for making loosing your time. I’m a looser 🙂  
> > it’s from an Hash and not from and array
> 
> See the docs for Hash#delete, Hash#delete\_if, and Hash#reject! (That  
> exclamation point is part of the method name.)
> 
> David

I’m done!  
Thanks David
