Associative array/Iteration: Difference between revisions

→‎{{header|Rust}}: Added output, formatted according to the guidelines
(→‎{{header|Rust}}: Added output, formatted according to the guidelines)
Line 2,135:
=={{header|Rust}}==
<lang Rust>use std::collections::HashMap;
 
fn main() {
let mut squares = HashMap::new();
squares.insert("one", 1i321);
squares.insert("two", 4);
squares.insert("three", 9);
for key in squares.keys() {
println!("Key {}", key);
}
for value in squares.values() {
println!("Value {}", value);
}
for (key, value) in squares.iter() {
println!("{} => {}", key, value);
}
}</lang>
{{out}}
<pre>
Key three
Key two
Key one
Value 9
Value 4
Value 1
three => 9
two => 4
one => 1
</pre>
 
=={{header|Scala}}==