Swift Language Guide 2 - Basic Operators Flashcards

1
Q

Jake druhy operatoru jsou ve Swiftu?

A

Unarni, binarni a ternarni.

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

Co dela prirazovaci operator?

A

Inicializuje nebo updatuje konstantu nebo promennou.

let a = 10

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

Jake jsou aritmeticke operatory?

A

+, -, *, /.

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

Co dela zbytkovy operator?

A

Vraci zbytek po deleni.

9 % 4 // equals 1

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

Co dela inkrementacni a dekrementacni operatory?

A

Zvyseje o 1, resp. snizuje o 1.

++a

–b

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

Jake jsou unarni operatory?

A

Minusovy a plusovy operator

-a

+b

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

Co je to slozeny prirazovaci operator?

A

Kombinuje prirazovaci operator s jinym operatorem.

a += 10

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

Jake jsou porovnavaci operatory?

A

==, !=, >, <, >=, <=.

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

Jakou formu ma ternarni podminkovy operator a co dela?

A

Ma formu otazka ? odpoved1 : odpoved2. Pokud je otazka pravdiva provede se odpvoed1 jinak odpoved2.

let contentHeight = 40

let hasHeader = true

let rowHeight = contentHeight + (hasHeader ? 50 : 20)

// rowHeight is equal to 90

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

Co je to nil slucovaci operator a jakou ma formu?

A

Ma formu (a ?? b). Pokud optional a neni nil, potom se unwrapuje a, pokud je nil vraci hodnotu b.

let defaultColorName = “red”

var userDefinedColorName: String? // defaults to nil

var colorNameToUse = userDefinedColorName ?? defaultColorName

// userDefinedColorName is nil, so colorNameToUse is set to the default of “red”

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

Jake jsou rozsahove operatory a jakou maji syntaxi.

A

Uzavreny rozsahovy operator (a..b).

Z poloviny otevreny rozsahovy operator (a..

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

Jake jsou logicke operatory?

A

NOT (!a), AND (a && b), OR (a || b).

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