Section 1

Preview this deck

When would you use a tuple?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (34)

Section 1

(34 cards)

When would you use a tuple?

Front

If you need a specific, fixed collection of related values where each item has a precise position or name. let address = (house: 555, street: "farr rd", city: "Spokane")

Back

String

Front

Collection of letters

Back

Enum Associated Values

Front

Attaching values to a case ex enum Activity { case running(destination: String) case talking(topic:String) } let talking = Activity.talking(topic:"Football")

Back

Boolean

Front

Data type that stores true or false

Back

Integer

Front

A whole number

Back

Type Inference

Front

Swift is able to infer the type of something based on how you create it. Example : let str = "Hi" - here Xcode will know its a string because "" instead of let str : String = "Hi"

Back

When would you use an array?

Front

If you need a collection of values that can contain duplicates, or the order of your items matters

Back

When would you use a set?

Front

If you need a collection of values that must be unique or you need to be able to check whether a specific item is in there extremely quickly

Back

Complex Types

Front

Arrays, sets, tuples, dictionaries, enumerations

Back

Conditions - If Else

Front

if __ == __ { } else if __ >__{ } else{ }

Back

Compound Operators

Front

+=, -=, *=, /=, %=. Also known as combined assignment operators and arithmetic assignment operators.

Back

Remainder Operator

Front

denoted as % 13 % 4 will return 1 because 4 goes into 13 three times with remainder 1

Back

Type-safe language

Front

We cant mix types like in Swift

Back

What to do for Multi-Line Strings

Front

Start and end with 3 double quotes (put \ after each line to get rid of line breaks in the strings, it makes it cleaner)

Back

Enum Raw Values

Front

We can assign values to enums. enum planets: Int { case mercury } mercury is 0 or we can set it = to 1 so it starts at 1

Back

How to create an empty collection

Front

() at end with data types between brackets ex var teams = [String : String]() teams["Ryan"] = "Red" *note set is done differently var words = Set<String>()

Back

Double

Front

Double-precision floating-point number

Back

Collections

Front

Arrays, sets and dictionaries. They collect values together in one place.

Back

Simple Types

Front

Variables, strings and integers, doubles, booleans, constants, string interpolation

Back

nil

Front

Swift's term for missing data. An optional that has no value will be set to nil.

Back

Sets

Front

Collections of values just like arrays except they are not stored in any order and all items must be unique (no duplicates), high-performance and contributes to Hashable protocol let car = Set(["ford", etc])

Back

Variable

Front

Any named piece of data in your code that may change when your program runs - denoted : var

Back

Constant

Front

A named piece of data in your code that may not change when your program runs - denoted: let

Back

String Interpolation

Front

The ability for Swift to insert the values of variables and constants into strings, such as "Hello, \(name)" (its the \() )

Back

Enumeration (Enum)

Front

A way of defining groups of related values that are easier to remember and safer that just using string or integers. ex enum Result { case success case failure } let result1 = Result.success

Back

Dictionary

Front

A high-performance, unordered collection of values stored using a key-value pair for fast access.Example: let heights = [ "ryan" : 1.78, etc. ] heights["ryan"] type annotations: [string:double] or [string:string]

Back

Switch Statement

Front

can be used to code a multiple-alternative selection structure

Back

Combining Operators

Front

&& - "and" || - "or" used especially in If statements

Back

Array

Front

A sequential collection of values of any type that is stored as a single value, such as an array of names in a band let cars = ["ford", etc] car[0]

Back

Ternary Operator

Front

an operator that takes three arguments. print(first == second ? "cars are same" : "cards are different")

Back

Dictionary Default Values

Front

Replaces the nil. let favcandy = [ "ryan" : "baby ruth" ] favcandy[kristin, default: "Unknown"]

Back

Comparison Operator

Front

the mathematical operator to compare: ==, !=, <, <=, >, >=

Back

Operator overloading

Front

The ability for one operator, such as + to do multiple things depending on how it's used. We can do sums of ints or join arrays or strings.

Back

Tuple

Front

A fixed-size collection of values of any type, you cant add/remove items, you cant change type of items in a tuple, you can access items in a tuple using numerical positions or by naming them var name = (first: "taylor", last: "swift") name.0 or name.first

Back