# Re: associative array naming indirection

**URL:** <https://www.ruby-forum.com/t/re-associative-array-naming-indirection/63863>\
**Category:** Ruby\
**Created:** [June 19, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/re-associative-array-naming-indirection/63863 "2006-06-19T23:55:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [June 19, 2006, 11:55pm UTC](https://www.ruby-forum.com/t/re-associative-array-naming-indirection/63863/1 "2006-06-19T23:55:50Z")

</div>

> > the array is in has a method that takes an array of string values.  
> > end
> 
> foo(:a, :b, :c)
> 
> You can read about Array#zip and Array#flatten on the documentation  
> pages, or by using ri from the terminal, e.g.
> 
> $ ri Array#zip
> 
> Cheers,  
> Daniel

The above works great if you’re limited to the standard library.  
However, if you’re allowed to use third party packages, I prefer hash  
slices for this sort of thing:

require ‘hashslice’

def adddata(_data)  
 @pageData[_@labels] = \*data  
end

IMHO this behavior should exist in the current Hash class. 🙂

Regards,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [June 20, 2006, 10:52am UTC](https://www.ruby-forum.com/t/re-associative-array-naming-indirection/63863/2 "2006-06-20T10:52:43Z")

</div>

Berger, Daniel wrote:

> > > the array is in has a method that takes an array of string values.  
> > > end  
> > > Hash.[] takes an argument list with the even items being the keys and  
> > > foo(:a, :b, :c)  
> > > The above works great if you’re limited to the standard library.  
> > > However, if you’re allowed to use third party packages, I prefer hash  
> > > slices for this sort of thing:
> 
> require ‘hashslice’
> 
> def adddata(_data)  
> @pageData[_@labels] = \*data  
> end
> 
> IMHO this behavior should exist in the current Hash class. 🙂

I agree, and I’m using it myself. I just usually try to limit myself to  
the standard library when answering questions on this list, to minimize  
the hazzle the user has to go through.

Cheers,  
Daniel
