-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abb4218
commit 35937bf
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 20CYS312 - Principles of Programming Languages | ||
![](https://img.shields.io/badge/Batch-21CYS-lightgreen) ![](https://img.shields.io/badge/UG-blue) ![](https://img.shields.io/badge/Subject-PPL-blue) <br/> | ||
![](https://img.shields.io/badge/Lecture-2-orange) ![](https://img.shields.io/badge/Practical-3-orange) ![](https://img.shields.io/badge/Credits-3-orange) | ||
|
||
## Lecture 5 - Misc | ||
![](https://img.shields.io/badge/-8th_May-orange) | ||
|
||
``` | ||
fn main() { | ||
let number = 13; | ||
// TODO ^ Try different values for `number` | ||
match number { | ||
// Match a single value | ||
1 => println!("One!"), | ||
// Match several values | ||
2 | 3 | 5 | 7 | 11 => println!("This is a prime"), | ||
// TODO ^ Try adding 13 to the list of prime values | ||
// Match an inclusive range | ||
13..=19 => println!("A teen"), | ||
// Handle the rest of cases | ||
_ => println!("Ain't special"), | ||
// TODO ^ Try commenting out this catch-all arm | ||
} | ||
let boolean = true; | ||
// Match is an expression too | ||
let binary = match boolean { | ||
// The arms of a match must cover all the possible values | ||
false => 0, | ||
true => 1, | ||
// TODO ^ Try commenting out one of these arms | ||
}; | ||
println!("{} -> {}", boolean, binary); | ||
} | ||
``` |