# What the...? Hash does not have a key it really should have!

**URL:** <https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784>\
**Category:** Ruby\
**Created:** [August 10, 2007, 7:47pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784 "2007-08-10T19:47:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 10, 2007, 7:47pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/1 "2007-08-10T19:47:25Z")

</div>

Hi all

irb(main):001:0\> conversion\_classes = {  
irb(main):002:1\* ‘Music labels’ =\> ‘MusicLabel’,  
irb(main):003:1\* ‘Music artists’ =\> ‘MusicArtist’,  
irb(main):004:1\* ‘Online Shops’ =\> ‘OnlineShop’,  
irb(main):005:1\* ‘Psy Communities’ =\> ‘PsyCommunity’,  
irb(main):006:1\* }  
=\> {“Psy Communities”=\>“PsyCommunity”, “Music labels”=\>“MusicLabel”,  
“Online Shops”=\>“OnlineShop”, “Music artists”=\>“MusicArtist”}  
irb(main):007:0\> conversion\_classes.has\_key? “Music Labels”  
=\> false

What the heck is wrong here? I’m feeling quite blind at the moment, lol!

Thanks  
Josh

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 10, 2007, 7:53pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/2 "2007-08-10T19:53:15Z")

</div>

Alle venerdÃ¬ 10 agosto 2007, Joshua M. ha scritto:

> irb(main):007:0\> conversion\_classes.has\_key? “Music Labels”  
> =\> false
> 
> What the heck is wrong here? I’m feeling quite blind at the moment, lol!
> 
> Thanks  
> Josh

I’d say because in the hash you set the key ‘Music labels’, then you ask  
if it  
has the key ‘Music Labels’.

Stefano

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 10, 2007, 7:54pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/3 "2007-08-10T19:54:15Z")

</div>

Hi –

On Sat, 11 Aug 2007, Joshua M. wrote:

> irb(main):007:0\> conversion\_classes.has\_key? “Music Labels”  
> =\> false
> 
> What the heck is wrong here? I’m feeling quite blind at the moment, lol!

You’re capitalizing “Labels”.

David

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 10, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/4 "2007-08-10T20:02:31Z")

</div>

I’m really a genius… thanks good it’s weekend now =)

Thank you guys

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 11, 2007, 4:18pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/5 "2007-08-11T16:18:49Z")

</div>

Joshua M. wrote:

> irb(main):002:1\* ‘Music labels’ =\> ‘MusicLabel’,  
> sion\_classes.has\_key? “Music Labels”

> What the heck is wrong here? I’m feeling quite blind at the moment, lol!

I lined them up (for proportional fonts). See the difference yet?

---

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [August 10, 2007, 7:58pm UTC](https://www.ruby-forum.com/t/what-the-hash-does-not-have-a-key-it-really-should-have/111784/6 "2007-08-10T19:58:15Z")

</div>

On 8/10/07, Joshua M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):007:0\> conversion\_classes.has\_key? “Music Labels”  
> =\> false
> 
> What the heck is wrong here? I’m feeling quite blind at the moment, lol!

You’re creating the key with a lowercase ‘l’ and trying to read it out  
with a capital ‘L’…

Is that the blunder?

hth,  
-Harold
