Associative array/Iteration: Difference between revisions
Content added Content deleted
(Updated to work without warning with version 1.4 of Nim.) |
(Add Crystal implementation) |
||
Line 722: | Line 722: | ||
! : 71 |
! : 71 |
||
</pre> |
</pre> |
||
=={{header|Crystal}}== |
|||
<lang crystal>dict = {'A' => 1, 'B' => 2} |
|||
dict.each { |pair| |
|||
puts pair |
|||
} |
|||
dict.each_key { |key| |
|||
puts key |
|||
} |
|||
dict.each_value { |value| |
|||
puts value |
|||
}</lang> |
|||
{{out}} |
|||
<pre>{'A', 1} |
|||
{'B', 2} |
|||
A |
|||
B |
|||
1 |
|||
2</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |