Created
July 23, 2014 12:35
-
-
Save MatejLach/e5eb335aee6aaa33e383 to your computer and use it in GitHub Desktop.
Pattern matching in Rust...
This file contains hidden or 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() { | |
let x = 3.75f64; | |
match x { | |
1.0..1.99 => println!("x is between one and two"), | |
2.0..2.99 => println!("x is between two and three"), | |
3.0..3.99 => println!("x is between three and four"), | |
4.0..4.99 => println!("x is between four and five"), | |
5.0..5.99 => println!("x is between five and six"), | |
_ => println!("x is bigger than five") // catches all other possible values of `x` | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the latest working code should be like this