Created
January 9, 2014 05:07
-
-
Save quux00/8329661 to your computer and use it in GitHub Desktop.
Simple Rust iteration example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::rand::{task_rng, Rng}; | |
fn main() { | |
let names = ["Alice", "Bob", "Carol"]; | |
for name in names.iter() { | |
let v = task_rng().shuffle(~[1,2,3]); | |
for num in v.iter() { | |
println!("{:s} says: {:d}", *name, *num); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment