# Hash Problem

**URL:** <https://www.ruby-forum.com/t/hash-problem/192071>\
**Category:** Ruby\
**Created:** [July 23, 2010, 9:58am UTC](https://www.ruby-forum.com/t/hash-problem/192071 "2010-07-23T09:58:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [July 23, 2010, 9:58am UTC](https://www.ruby-forum.com/t/hash-problem/192071/1 "2010-07-23T09:58:30Z")

</div>

Hi  
How can I a hash with one key and some( for example 5 ) value?

---

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [July 23, 2010, 10:25am UTC](https://www.ruby-forum.com/t/hash-problem/192071/2 "2010-07-23T10:25:57Z")

</div>

On Fri, Jul 23, 2010 at 9:58 AM, Amir E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi  
> How can I a hash with one key and some( for example 5 ) value?

h = {:key =\> 5}

or if you want to add it later:

h = {}

h[:key] = 5

Jesus.

---

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [July 23, 2010, 10:44am UTC](https://www.ruby-forum.com/t/hash-problem/192071/3 "2010-07-23T10:44:21Z")

</div>

Amir E. wrote:

> Hi  
> How can I a hash with one key and some( for example 5 ) value?

h = Hash.new()

h[‘a\_key’] = [1,2,‘three’,4,5]

p h
