Created
September 27, 2020 16:58
-
-
Save buzztaiki/94134a6f78be93df18fad46175c1eba3 to your computer and use it in GitHub Desktop.
Rustの式と文
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 x() -> i32 { | |
let x = 10; | |
return x; | |
} | |
// セミコロンがないと式になる。式は値を返す。文全体は式になる。 | |
fn y() -> i32 { | |
let x = 10; | |
x | |
} | |
// 文の値は () になる。よって 10; とすると返値のエラーとなる。 | |
// fn z() -> i32 { | |
// 10; | |
// } | |
fn main() { | |
println!("{}", x()); | |
println!("{}", y()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment