Skip to content

Instantly share code, notes, and snippets.

@toshimasa-nanaki
Last active December 2, 2018 04:14
Show Gist options
  • Save toshimasa-nanaki/e8b15f4b138cb216b247484ceff4118d to your computer and use it in GitHub Desktop.
Save toshimasa-nanaki/e8b15f4b138cb216b247484ceff4118d to your computer and use it in GitHub Desktop.
Rust 関数(戻り値考慮)
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