Control Flow Flashcards

1
Q

Use _____ and _____ to make conditionals,

A

if, switch

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

use _____-in, _____, _____, and _____-while to make loops.

A

for-in, for, while, repeat-while

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

Parentheses around the condition or loop variable are _____.

A

optional

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

An optional value either contains a value or contains nil to indicate that a value is missing. Type _____ after the type of a value to mark the value as optional.

A

?

var optionalString: String? = “Hello”

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

_____ support any kind of data and a wide variety of comparison operations—they aren’t limited to integers and tests for equality.

A

Switches

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

You use _____ to iterate over items in a dictionary by providing a pair of names to use for each key-value pair.

A

for-in

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

_____ are an unordered collection, so their keys and values are iterated over in an arbitrary order.

A

Dictionaries

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

Use _____ to repeat a block of code until a condition changes. The condition of a loop can be at the end instead, ensuring that the loop is run at least once.

A

while

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

You can keep an index in a loop—either by using _____ to make a range of indexes or by writing an explicit initialization, condition, and increment.

A

..<

These two loops do the same thing:

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