Created
December 3, 2018 13:39
-
-
Save toshimasa-nanaki/33a535d931ec811e068860a7d9eb3427 to your computer and use it in GitHub Desktop.
Rust ループ(break文、continue文)
This file contains 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
fn main() { | |
//break文が使える。 | |
let mut x = 7; | |
loop { | |
x -= 1; | |
println!("{}", x); | |
if x == 3 { break; } | |
} | |
//continue文が使える。 | |
for y in 0..10 { | |
if y % 2 == 0 { continue; } | |
println!("{}", y); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment