# Hash Value Assignment Bug?

**URL:** <https://www.ruby-forum.com/t/hash-value-assignment-bug/48364>\
**Category:** Ruby\
**Created:** [November 19, 2005, 12:56pm UTC](https://www.ruby-forum.com/t/hash-value-assignment-bug/48364 "2005-11-19T12:56:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [November 19, 2005, 12:56pm UTC](https://www.ruby-forum.com/t/hash-value-assignment-bug/48364/1 "2005-11-19T12:56:49Z")

</div>

I have been trying to build a ACL system, and found what I believe is a  
bug.

> > result = {“return\_value”=\>nil, “allow”=\>“t”, “id”=\>“1000002”}  
> > =\> {“allow”=\>“t”, “return\_value”=\>nil, “id”=\>“1000002”}

> > access = { :acl\_id =\> result[“acl\_id”], :return\_value =\>  
> > result[“return\_value”], :allow =\> allow }  
> > =\> {:return\_value=\>nil, :acl\_id=\>nil, :allow=\>true}

What I was trying to do, is set the access hash values with the values  
from  
the result Hash. What I result with, is null values.

Warmest regards,  
Nathan.

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [November 19, 2005, 1:33pm UTC](https://www.ruby-forum.com/t/hash-value-assignment-bug/48364/2 "2005-11-19T13:33:05Z")

</div>

Your are assigning a key of :id to result, but accessing a key  
of :acl\_id in the seconds assignment.  
It is not clear what your intentions are with :allow=\>allow - is  
allow defined somewhere, or did you mean :allow=\>result[:allow] ??

---

<div class="post-metadata">

**Author:** ![nshb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df788c/32.png) [@nshb](https://www.ruby-forum.com/u/nshb)\
**Post date:** [November 19, 2005, 2:57pm UTC](https://www.ruby-forum.com/t/hash-value-assignment-bug/48364/3 "2005-11-19T14:57:32Z")

</div>

> > > > access = { :acl\_id =\> result[“acl\_id”], :return\_value =\>  
> > > > result[“return\_value”], :allow =\> allow } =\> {:return\_value=\>nil,  
> > > > :acl\_id=\>nil, :allow=\>true}

Thanks Derek, appears it was a simple typo. Shortly after I sent this I  
fixed a bug with the local allow variable which wasn’t testing for (t|f)  
but  
rather 1|0. After that was fixed, one of the nil’s was removed, this  
explains the other.

Warmest regards,  
Nathan.
