expressions Flashcards

know all

1
Q

what is the difference between an expression and a statement?

A

expressions have values. Statements don’t.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can if produce a value?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

can match produce a value?

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

can a match expression be passed as a parameter to a function

A

yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the syntax for a match statement

A
let phrase = match something {
0 => "zero", 
1  => "two",
_ => "three"
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is the syntax for the four looping expressions

A

while condition {}

while let pattern = expr {}

loop {}

for pattern in collection {}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

write a for loop that prints 1 through 5

A

for i in 1..6 {
println!(“{}”, i );
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly