Last active
December 2, 2018 04:14
-
-
Save toshimasa-nanaki/e8b15f4b138cb216b247484ceff4118d 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 main() { | |
println!("When x is doubled, {}.", times_number(7)); | |
} | |
fn times_number(x: i32) -> i32 { | |
x * 2 //セミコロンがない=i32型で返す。(セミコロンがあると型なしになりコンパイルエラー) | |
// return x * 2; (もちろんこんなことはできる) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment