Does zsh support hash table as a built-in data type?

6

2

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

Yad Smood

Posted 2013-08-23T14:18:36.610

Reputation: 223

Answers

15

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]}

Fanfurlio

Posted 2013-08-23T14:18:36.610

Reputation: 181

2Just a remark: This kind of variables are called associative arrays in zsh. – mpy – 2013-08-24T12:13:10.193

1So they are in PHP, also; it's the rest of the world that calls them hash tables. – Fanfurlio – 2013-08-26T08:56:01.330