Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If supported, which version of zsh should I use to take advantage of this feature? How to declare and use it in code?

share|improve this question

migrated from stackoverflow.com Aug 24 '13 at 12:10

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 4 down vote accepted

Zsh supports hash tables, a quick google search returns many results, here's one

You must first typeset the variable:

% typeset -A hash

then you can store items in the table:

% hash[brown]="mm..  hash browns"
% hash[table]="clever data structure"

then you recover them as usual with arrays:

% print ${hash[brown]}
share|improve this answer
1  
Just a remark: This kind of variables are called associative arrays in zsh. –  mpy Aug 24 '13 at 12:13
    
So they are in PHP, also; it's the rest of the world that calls them hash tables. –  Fanfurlio Aug 26 '13 at 8:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.