expressions Flashcards
know all
1
Q
what is the difference between an expression and a statement?
A
expressions have values. Statements don’t.
2
Q
Can if produce a value?
A
yes
3
Q
can match produce a value?
A
yes
4
Q
can a match expression be passed as a parameter to a function
A
yes
5
Q
what is the syntax for a match statement
A
let phrase = match something { 0 => "zero", 1 => "two", _ => "three" }
6
Q
what is the syntax for the four looping expressions
A
while condition {}
while let pattern = expr {}
loop {}
for pattern in collection {}
7
Q
write a for loop that prints 1 through 5
A
for i in 1..6 {
println!(“{}”, i );
}