6

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

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

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

14

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]}
  • 2
    Just a remark: This kind of variables are called associative arrays in zsh. – mpy Aug 24 '13 at 12:13
  • 1
    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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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