Associative array/Iteration: Difference between revisions
m
→{{header|Sidef}}: removed the useless semicolons
(→{{header|Rust}}: Added output, formatted according to the guidelines) |
m (→{{header|Sidef}}: removed the useless semicolons) |
||
Line 2,274:
key1 => 'value1',
key2 => 'value2',
)
# Iterate over key-value pairs
hash.each { |key, value|
say "#{key}: #{value}";
}
# Iterate only over keys
hash.keys.each { |key|
say key;
}
# Iterate only over values
hash.values.each { |value|
say value;
}
{{out}}
<pre>key1: value1
|