Hash from two arrays: Difference between revisions
Content added Content deleted
MaiconSoft (talk | contribs) No edit summary |
(Added Wren) |
||
Line 2,196: | Line 2,196: | ||
{{out|Returns}} |
{{out|Returns}} |
||
<pre>{a 1 b 2 c 3}</pre> |
<pre>{a 1 b 2 c 3}</pre> |
||
=={{header|Wren}}== |
|||
Wren's built-in Map class does not guarantee (as here) that iteration order will be the same as the order in which elements were added. |
|||
<lang ecmascript>var keys = [1, 2, 3, 4, 5] |
|||
var values = ["first", "second", "third", "fourth","fifth"] |
|||
var hash = {} |
|||
(0..4).each { |i| hash[keys[i]] = values[i] } |
|||
System.print(hash)</lang> |
|||
{{out}} |
|||
<pre> |
|||
{2: second, 1: first, 3: third, 5: fifth, 4: fourth} |
|||
</pre> |
|||
=={{header|zkl}}== |
=={{header|zkl}}== |