Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

pws-19: comparing (k) and (I) for hashes



>From manual I got the impression, that ${(k)...} and ${...[(I)...]} do the
same - both return the keys of matching elements. Cf. (I) description:

`I'
     like ``i', but gives the index of the last match, or all possible
     matching keys in an associative array.

In case of parameters hash, the keys are parameter names, so

bor@itsrm2:~%> print -l ${(k)parameters[(R)scalar*]} | grep foo
foo
bor@itsrm2:~%>

(as expected), but

bor@itsrm2:~%> print -l ${parameters[(I)scalar*]} | grep foo
bor@itsrm2:~%>

What do I do wrong?

/andrej




Messages sorted by: Reverse Date, Date, Thread, Author