On Sun, 6 Jun 2021, Artur T. wrote:
Hi all,
I've stumbled about this puzzling and seemingly simple task:
Iterate over a a bundle and print the key-value pairs.
Here a simple example:
<hansl>
bundle B = _(a = 1, b = 2)
loop foreach i B
printf "key: %s, value: %d\n", "$i", $i
# OR: printf "key: $i, value: %d\n", , $i
endloop
</hansl>
That works as all elements in B are numeric.
But obviously not otherwise.
First, what's wrong with "print B"? (which is now ordered by type
then alphabetically by key)
But alternatively, you could do:
strings S = getkeys(B)
loop foreach i S
printf "key $i:\n"
print B["$i"]
endloop
Note "print <bundle-member>" requires current git, but otherwise
"eval B["$i"] should work.
Allin