Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Closure

This code tries to use map to triple each number, but the closure syntax is wrong! Fix it.

Fix the code so it prints:

text
[3, 6, 9]

Hint: Closures use |x| not (x) for parameters.

rust
fn main() {
let numbers = vec![1, 2, 3];
let tripled: Vec<i32> = numbers.iter().map((x) x * 3).collect();
println!("{:?}", tripled);
}