Advertisement
cwchen

[Rust] if as an expression

Aug 22nd, 2017
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.27 KB | None | 0 0
  1. fn main() {
  2.     let score = 83;
  3.  
  4.     let grade = if score > 90 {
  5.         "A"
  6.     } else if score > 80 {
  7.         "B"
  8.     } else if score > 70 {
  9.         "C"
  10.     } else if score > 60 {
  11.         "D"
  12.     } else {
  13.         "F"
  14.     };
  15.  
  16.     assert_eq!(grade, "B");
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement