self study Flashcards
(185 cards)
What does Built-In mean?
Refers to functionalities, types, or features that are an integral part of the Swift language itself.
These are provided directly by the Swift standard library or are part of the Swift compiler, and they are readily available without the need for additional imports or external dependencies.
Functions and methods with no return type have an implicit return type of ______
Void
A struct is a ____ type
Value
A class is a ____ type
Reference
The language used by Apple before Swift:
Objective-C
Are variables always initialized before use?
Yes
Fundamental Data Types:
Integers, Double, Bool, String
Collection Types:
Array, Set, Dictionary
A tuple is an ____ type
Advanced
The language helps you to be clear about the types of values your code can work with.
For example, if your code requires a String, type safety prevents you from passing an Int by mistake
Type-Safe
Swift performs type-safe checks when ____ the code
Compiling
Must be declared before they’re used
Constants and Variables
Enables a compiler to deduce the type of a particular expression automatically when it compiles your code, simply by examining the values you provide
Type Inference
Write a ___________ by placing a colon after the constant of variable name, followed by a space, followed by the name of the type to use
Type Annotation
In the following code, the “String” word can be defined as:
var myWord: String
Type Annotation
It’s a value that appears directly in your source code. The number 42 is a ______
E.g let meaningOfLife = 42
Literal Value
If you need to give a constant or variable the same name as the reserved Swift keyword, surround the keyword with ____
backticks (`)
Include the name of a constant or variable as a placeholder in a longer string
String interpolation
How do you represent, single, multiple lines comments?
// Single line
/* Multiple lines */
/* This is the start of the first multiline comment. /* This is the second, nested multiline comment. */ This is the end of the first multiline comment. */
Whole numbers with no fractional component, Signed positive, zero, negative.
Integers
Represents a 64-bit floating-point number and it is preferred and inferred when you don’t specify a type
Double
Values are referred to as logical because they can only be true or false
Booleans (Bool)
The values within a ____ can be of any type and don’t have to be of the same type as each other
tuple
You can ____ a tuples contents into separate constants or variables
decompose