Getting Started with App Development [Section 3: Constants, Variables, & Data Types] Flashcards

1
Q

___________ are most frequently used to explain difficult sections of code, provide copyright information, at the top of a file, and to offer dating information

A

Comments

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

Swift also supports ___________ _____________, which group multiple values into a single constant or variable

A

collection types

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

One collection type is named an __________; it stores an ordered list of values

A

Array

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

Another collection type is named a __________, which contains keys that help you look up specific values

A

Dictionary

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

Here’s an example of creating a type definition

A

struct Person {
let firstName: String
let lastName: String

func sayHello() {
print(”Hello there! My name is (firstName) (lastName).”)
}
}

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

A ________ _________ declares the information it stores and its capabilities or actions

A

type definition

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

The information that a type definition stores

A

property

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

A type definition’s action/ capability

A

method

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

When creating a type and assigning it to a variable or constant, you’re making a version or ________ of the type

A

instance

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

Swift is a type-_______ language

A

safe

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

Type-safe languages encourage or require clarity about the types of values your ______ can work with

A

code

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

When compiling your code, Swift performs _________ __________ on all of your constraints and variables; it also flags any mismatched types as errors

A

type checking

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

In Swift, you’re unable to assign a ________ of one type to a variable of another type

A

variable

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

Swift allows you to put _________ in your numbers as a way of formatting for easier reading

A

underscores

e.g.,

var largeUglyNumber = 1000000000
var largePrettyNumber = 1_000_000_000

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

Swift uses _________ __________ to make assumptions about the type based on the value assigned to the constant or variable

A

type inference

e.g.,

let cityName = “San Francisco”
// “San Francisco” is obviously a String, so the compiler
automatically assigns the type of cityName to a String.

let pi = 3.1415927
// 3.1415927 is a number with decimal points, so the compiler
automatically assigns the type pi to a Double.

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

A case when it’s useful/ required to explicitly specify the type of a constant or variable is known as a…

A

type annotation

e.g.,

let cityName: String = “San Francisco”

let pi: Double = 3.1415927

17
Q

Whenever you define a constant or variable, you must either specify a type using a type annotation or _________ it a value that the compiler can use to infer the type

A

assign