Swift Language Guide 3 - Strings and Characters Flashcards

1
Q

Co je to String a Character?

A

Character je jediny znak a Stringn je usporadana kolekce Character.

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

Jak zapisujeme String a Character?

A

Piseme String a Character hodnoty mezi dvojitymi ( “ ).

let myString = “Hello”

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

Jak inicializujeme prazdny String?

A

Muzeme pouzit prazdny literal.

var emptyString = “”

Muzeme pouzit inicializacni syntaxi.

var anotherEmptyString = String()

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

Co dela property isEmpty?

A

Property isEmpty patri typu String a muzeme pomoci neho zjistit, zda je String prazdny retezec.

if emptyString.isEmpty {

println(“Nothing to see here”)

}

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

Co je string mutability?

A

Jine oznaceni pro moznost modifikace hodnoty ve String. String mutability je mozne pouze u promennych.

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

Co znamena, ze Stringn je hodnotovy typ?

A

To znamena, ze hodnoty Stringu se kopiruji. Pokud zkopirujeme hodnotu jednoho String do jineho, budou mit stejnou hodnotu, ale zmenime-li pozdeji hodnotu jednoho, nemenime hodnotu toho druheho, protoze jsou na sobe nezavisle.

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

Jak pripojime String?

A

Pouzijeme operator ( + ).

var welcome = string1 + string2

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

Jak doplnime retezec na konci String?

A

Pouzijeme slozeny prirazovaci operator ( += ).

instruction += string2

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

Co dela metoda append?

A

Umoznuje na konci String pridat znak.

welcome.append(“!”)

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

Jake jsou escape sekvence?

A

\0 - znak null
\ - backslash
\t - tabulator
\n - novy radek
\r - navrat voziku
\” - dvojita uvozovka
\’ - jednoducha uvozovka

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

Co dela metoda countElement?

A

Pocita pocet znaku ve String.

let unusualMenagerie = “Koala

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

Jake jsou zpusoby na porovnavani retezcu?

A

Retezcova a znakova rovnost, prefixni rovnost, suffixni rovnost.

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

Jak se pouziva retezcova rovnost?

A

Pouzijeme operatort ( == ) nebo ( != ).

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

Jak se pouziva prefixni a suffixni rovnost.

A

Pouzijeme metodu hasPrefix nebo hasSuffix.

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