diff options
| author | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-11-17 17:59:18 -0500 |
|---|---|---|
| committer | Carol (Nichols || Goulding) <carol.nichols@gmail.com> | 2015-11-17 17:59:18 -0500 |
| commit | c2bd282af27737a759eefca1eca79bc608d7684e (patch) | |
| tree | 8a42b9a0c923889d87350aa1318f51bcb090274b /if/if1.rs | |
| parent | f1ce5f4454be984f161c586361ed858a65357a14 (diff) | |
Make @ConnyOnny's example be 1st example in the `if` section! :tada:
Diffstat (limited to 'if/if1.rs')
| -rw-r--r-- | if/if1.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/if/if1.rs b/if/if1.rs new file mode 100644 index 0000000..c5d2bbf --- /dev/null +++ b/if/if1.rs @@ -0,0 +1,47 @@ +fn bigger(a: i32, b:i32) -> i32 { + // Complete this function to return the bigger number! + // Do not use: + // - return + // - another function call + // - additional variables + // Scroll down for hints. +} + +fn main() { + assert_eq!(10, bigger(10, 8)); + assert_eq!(42, bigger(32, 42)); +} + + + + + + + + + + + + + + + + + + + + + + + + + + +// It's possible to do this in one line if you would like! +// Some similar examples from other languages: +// - In C(++) this would be: `a > b ? a : b` +// - In Python this would be: `a if a > b else b` +// Remember in Rust that: +// - the `if` condition does not need to be surrounded by parentheses +// - `if`/`else` conditionals are expressions +// - Each condition is followed by a `{}` block. |
