Section 1

Preview this deck

enum

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

7 years ago

Date created

Mar 1, 2020

Cards (205)

Section 1

(50 cards)

enum

Front

Back

let cat = ""; print(cat)

Front

write two separate statements let cat = "" and print(cat) on a single line

Back

class

Front

Back

static func

Front

Defines a type method. (for enums, structs )

Back

static | keyword

Front

- defines type methods / properties (structs, enums)

Back

type method

Front

a method that can be called via the type name without creating a class instance. Car.drive() You indicate _ by writing the static keyword before the method's func keyword. Classes may also use the class keyword to allow subclasses to override the superclass's implementation of that method.

Back

Int32

Front

type represented 32-bit number with no fractional component

Back

reference type

Front

Instances share a single copy of the data, and the type is usually defined as a class. Use when: -Comparing instance identity with === makes sense -You want to create shared, mutable state

Back

class func

Front

Defines a type method. (for class )

Back

mutating | keyword

Front

Back

x = "Value"

Front

set variable x of type String to string value "Value"

Back

var x:String

Front

provid type annotation for variable x, to indicate that the variable can store String values

Back

computed property

Front

- a function disguised as a property - used as a property, but it actually recalculates every single time it's called

Back

Int16.max

Front

access maximum value of 16-bit integer

Back

Int64

Front

type represented 64-bit number with no fractional component

Back

Double

Front

type represented a 64-bit floating-point number

Back

instance method

Front

Back

UInt

Front

unsigned integer type, which has the same size as the current platform's native word size

Back

*/

Front

multicomments end

Back

Int

Front

integer type, which has the same size as the current platform's native word size

Back

Float

Front

type represented a 32-bit floating-point number

Back

print("x = \(x)")

Front

insert current value of variable x in string "x = " with string interpolation

Back

final | keyword

Front

- prevents a method, property, or subscript from being overridden. You can mark an entire class as __ by writing the __ modifier before the class keyword in its class definition. Any attempt to subclass a __ class is reported as a compile-time error.

Back

Function Parameter Names

Front

These parameter names are only used within the body of the __ itself, and cannot be used when calling the function. These kinds of parameter names are known as local parameter names, because they are only available for use within the __'s body.

Back

let

Front

keyword for declaring constants

Back

var

Front

keyword for declaring variables

Back

Int8

Front

type represented 8-bit number with no fractional component

Back

type property

Front

- requires a default value - or be an optional (?) - or force unwrapped optional (!)

Back

Methods

Front

__ are functions that are associated with a particular type. Classes, structures, and enumerations can all define instance __, which encapsulate specific tasks and functionality for working with an instance of a given type.

Back

Double(x)

Front

integer value x to Double

Back

print(_:separator:terminator:)

Front

definition of print function

Back

/*

Front

multicomments start

Back

Self vs self

Front

Self - själva klasstypen, för att använda den typens function/class method self - själva objektet/ instansen (av en viss typ av class)?

Back

var x, y, z: Double

Front

define multiple related variables of the type Double on a sinlge line

Back

Int16

Front

type represented 16-bit number with no fractional component

Back

stored instance property

Front

non-computed property

Back

static var

Front

Back

//

Front

start of single line comments

Back

private(set)

Front

Back

defer

Front

here's some what I want you to do later, no matter what. - work will be executed as the method is exiting

Back

print(x, terminator: "")

Front

print current value variable x without a line break after

Back

Int8.min

Front

access minimum value of 8-bit integer

Back

struct

Front

Back

UInt8

Front

type represented unsigned 8-bit number with no fractional component

Back

value type

Front

Each instance keeps a unique copy of its data, usually defined as a struct, enum, or tuple. Acting as a unique instance of that data. Use when: - Comparing instance data with == makes sense -You want copies to have independent state -The data will be used in code across multiple threads

Back

print(x)

Front

print current value of variable x

Back

class | keyword

Front

- defines a type method / computed type property (protocols, class)

Back

class var

Front

Back

Functions

Front

Self-contained chunks of code that perform a specific task. You give a __ a name that identifies what it does, and this name is used to "call" the function to perform its task when needed.

Back

function

Front

Back

Section 2

(50 cards)

true, false

Front

Boolean constant values

Back

\u{n}

Front

arbitrary Unicode scalar n in string

Back

for char in string {}

Front

access individual Characters char for String string by iterating over the string with for statement

Back

let x = (y: 1, z: "1")

Front

declare variable x with tuple,name the individual elements in tuple y: 1, z: "1"

Back

assert(_:_:file:line:)

Front

definition of assert function

Back

+,-,*,/

Front

arithmetic operators

Back

if let y = x {}

Front

optional binding of optional's variable x with variable y in if statements

Back

x...

Front

one side range from x

Back

String(["x","y","z"])

Front

construct string by passing an array of characters "x","y","z"

Back

tuple

Front

group multiple values of any type into single compound value

Back

nil

Front

value of valueless state variable

Back

x ?? b

Front

nil-coalescing operator

Back

condition ? true_statement : false_statement

Front

ternary conditional operator for condition, true_statement and false_statement

Back

"""x"""

Front

multiline string literal "x"

Back

x.y

Front

access the value of named element y of tuple let x = (y: 1, z: "1")

Back

<

Front

comparison operator less than

Back

x..<y

Front

half-open range operator from x to y exclusive

Back

typealias new_type = UInt16

Front

define alternative name new_type for existing type UInt16

Back

>

Front

comparison operator greater than

Back

1-8

Front

number of hexadimical digits in Unicode scalar

Back

&&

Front

logical operator and

Back

let x: Int!

Front

declare optinal variable x of Int type for implicit unwrapping

Back

do { try x() } catch {}

Front

error handling of x function

Back

>=

Front

comparison operator greater than or equal to

Back

...x

Front

one side range to x

Back

"x"

Front

string literal "x"

Back

!=

Front

comparison operator not equal to

Back

Int?

Front

type represented optional type of Int

Back


Front

line feed in string

Back

var x: (Int, String)

Front

declare variable x of tuple groups together an Int and a String

Back

\\

Front

backslash in string

Back

bool

Front

type represented basic Boolean

Back

\0

Front

null character in string

Back

x!

Front

forced unwrapping of optional's value x

Back

func x() throws {}

Front

declare function x that can throw an error

Back

+=,-=

Front

compound assignment operators

Back

precondition(_:_:file:line:)

Front

definition of precondition function

Back

=

Front

assignment operator

Back

var x = String()

Front

declare variable x with initialization a new String

Back

\r

Front

carriage return in string

Back

!

Front

logical operator not

Back

x + y

Front

concatenate string x with character y

Back

==

Front

comparison operator equal to

Back

\t

Front

horizontal tab in string

Back

\

Front

escape character in strings

Back

var x = ""

Front

declare variable x as empty string assing an empty string literal

Back

%

Front

remainder operator

Back

<=

Front

comparison operator less than or equal to

Back

Character

Front

type represented character

Back

x...y

Front

close range operator from x to y inclusive

Back

Section 3

(50 cards)

for item in x {}

Front

iterate over array x with the for statement

Back

[1, 2]

Front

Array literals with elements 1, 2

Back

x.append(1)

Front

add a new item 1 to the end of array x

Back

x.isEmpty

Front

property for checking whether the count of set x is equal to 0

Back

for (index, item) in x.enumerated() {}

Front

iterate over array x with the for statement getting the integer index for each item

Back

x.sorted()

Front

method of set x that return the set's elements as an array using < operator

Back

x.remove(:at 0)

Front

remove item from set x at index 0

Back

x.union(y)

Front

method to create a new set with all of the values in both sets x and y

Back

x.remove(:at 0)

Front

remove item from array x at index 0

Back

x.index(of: "!")

Front

get index of "!" character in string xyz

Back

x.subtracting(y)

Front

method of set x to create a new set with values not in set y

Back

set

Front

collection of the same type values with no difined ordering

Back

Set<Character>()

Front

create an empty set

Back

[Int]()

Front

Creating empty array of Int short syntax

Back

x.remove(at: x.startIndex)

Front

remove single character from string x at index startIndex

Back

x.hasPrefix("xyz")

Front

check whether a string x has prefix "xyz"

Back

x.removeSubrange(x.startIndex...x.index(x.endIndex, offsetBy: -2))

Front

remove a substring from string x at range from first index to endIndex - 2

Back

x.endIndex

Front

property of string x to access the position after the last Character

Back

x.intersection(y)

Front

method to create a new set with only the values common to both sets x and y

Back

x.isSuperset(of: y)

Front

method to determine whether a set contains all of the values in set y

Back

x.startIndex

Front

property of string x to access the position of the first Character

Back

x.insert(1, at: 0)

Front

insert 1 into set x at index 0

Back

x.isEmpty

Front

property for checking whether the count of array x is equal to 0

Back

x[..<x.index(x.startIndex, offsetBy: 3]

Front

get substring from string x that include 2 first character of string x

Back

[0, 2, 4, 34].filter({$0 > 20})

Front

get new array with items from [0, 2, 4, 34] that greater then 20

Back

x.indices

Front

property of string x to access all of the inidces of individual chatacter in string

Back

x.isStrictSuperset(of: y)

Front

method to determine whether a set contains all of the values in set y, but sets x and y not equal

Back

Array<Double>

Front

Array type Double full syntax

Back

[0, 2, 4, 34].reduce({$0 > $1})

Front

reduce array [0, 2, 4, 34] to one single value

Back

[1, 2, 3, 4]

Front

result of [1, 2] + [3, 4]

Back

x.insert(1, at: 0)

Front

insert 1 into array x at index 0

Back

x[i]

Front

get item indexed i by subscript syntax for array x

Back

x.contains(1)

Front

check whether set x containst item 1

Back

x.count

Front

property of string x to retrieve a count of the character values in string

Back

+=

Front

alternative for append item in an array

Back

x[x.startIndex]

Front

get start Character from string x

Back

x.isSubset(of: y)

Front

method to determine whether all the values of set x are contained in set y

Back

Set<Type>

Front

set type syntax

Back

x.count

Front

get number of items in set x

Back

x.isStrictSubset(of: y)

Front

method to determine whether all the values of set x are contained in set y, but sets x and y not equal

Back

x.symmetricDifference(y)

Front

method to create a new set with values in either set x or y, but not both

Back

x.hasSuffix("xyz")

Front

check whether a string x has suffix "xyz"

Back

x.count

Front

porperty of array x to find out number of items in array

Back

x.removeLast()

Front

remove last item from array x

Back

x.splice([0, 1], atIndex: 0)

Front

insert array [0, 1] into array x at index 0

Back

x.index(_ :offsetBy:befor:after:)

Front

method of string x which corresponds to the position of each Character in the string

Back

[Double]

Front

Array type Double short syntax

Back

x.removeAll()

Front

remove all items from set

Back

[0, 2, 4, 34].map({String($0)})

Front

get new array with items from [0, 2, 4, 34] make them type of String

Back

Array(repeating: 0.0, count: 3)

Front

Creating array of Double with default value 0.0 with 3 elements

Back

Section 4

(50 cards)

func x(arg_x x: Int) {}

Front

difine function with parameter x of type Int with argument label arg_x without return value

Back

enum x: Int { case y}

Front

enumeration x with case y with Type of rowValue of type Int

Back

guard condition {} else {}

Front

guard syntax

Back

x.isDisjoin(with: y)

Front

method to determine whether two set have no values in common

Back

{x, y in body}

Front

closure function takes two values x, y with body inferring types form context

Back

case "a", "A":

Front

make switch with single case for both "a" and "A"

Back

enum x { case y case z}

Front

define enumeration with cases y and z

Back

if condition {} elese if {} else {}

Front

if statement for condition

Back

#available(iOS 10, macOS 10.12, *)

Front

availability condition for platform name iOS 10, version macOS 10.12, *

Back

_

Front

ommited argument label for first parameter in function

Back

x.count

Front

get number of items in dictionary x

Back

Dictionary<key, value>

Front

Dictionary syntax with key and value

Back

x.isEmpty

Front

property for checking whether the count of dictionary x is equal to 0

Back

[String: Int]()

Front

create emepty dictionary of type String for key and Int for value short syntax

Back

x[y]

Front

subscript syntax for dictionary x, key y

Back

func x(_ y: Double) {}

Front

define function x with variadic parameter y of type Double with ommmited argument lable without return value

Back

break label_name

Front

break labeled statement label_name

Back

func x(y: inout Double) {}

Front

define funciton x with inout parameter y of type Double

Back

Dictionary

Front

collectin stores associations between keys of the same type and values of the same type

Back

case (let x, 0):

Front

switch with case matching tuple (a, b) where a bind to x and b equal 0

Back

func x() -> (y: Int, z: String) {}

Front

define function without parameters with multipel return values y or type Int, and z of type String

Back

x[y] = z

Front

add new item in dictionary x with key y value z

Back

for i in 1..5 {}

Front

use for-in loop with numeric ranges

Back

break

Front

statement for end execution of an entire control flow statement

Back

Dictionary<String, Int>()

Front

create empty dictionary of type String for key and Int for value full syntax

Back

[key: value]

Front

Short hand syntax for Dictionary with key and value

Back

(Int, Int) -> String

Front

function type takes two Int value and return String

Back

x.updateValue(z, forKey: y)

Front

update value in dictionary x set value z for key y

Back

fallthrough

Front

C-like switch behavior

Back

{$0 > $1}

Front

closure function takes two values x, y return the value of statement x > y, short hand syntax

Back

continue

Front

statement for stop current loop and start again at the beginning of the next iteration through the loop

Back

case 5..<12:

Front

switch with case matching interval from 5 to 12 exclusive

Back

case let (x, y) where x == y:

Front

switch with case matching tuple (a, b) where a bind to x and b bind to y and x == y

Back

enum x {case y, z}

Front

enumeration x with cases y, z on a single line

Back

label_name: while condition {}

Front

labeled statement while with condition

Back

repeat {} while condition

Front

repeate statement for condition

Back

for (key, value) in x {}

Front

iterate over dictionary by key, value with for statement

Back

["x" : 1, "y" : 2]

Front

dictionary literal with items "x" : 1, "y" : 2

Back

func x(_ y: Int = ) {}

Front

define function x with parameter y of type Int with ommited argument label with default parameter value

Back

enum x {case x(Double)}

Front

enumeration x with case x with associated value of type Double

Back

switch value {case value: statement default: break}

Front

switch start for value

Back

case (1, 1):

Front

switch with case matching tuple

Back

while condition {}

Front

while statement with condition

Back

x.removeValue(forKey: y)

Front

remove item form dictionary x where key equal y

Back

{(Int, Int) -> String in body}

Front

closure function takes two Int value and return String with body}

Back

func x() {}

Front

define function x without paramters and return value

Back

@escping () -> Void

Front

escaping closure without parematers and return value

Back

enum x: Int { case y = 5 }

Front

enumeration enumeration x with case y with Type of rowValue of type Int assigned raw value 5

Back

func x(y: Int) -> Int {}

Front

define function x with parameter y of type Int with return value of type Int

Back

stride(form:to/through:by)

Front

function for ger integer range from other types

Back

Section 5

(5 cards)

x.insert("!",at: x.endIndex)

Front

insert Character "!" into a string x at the endIndex

Back

enum x: Int { indirect case y(x)}

Front

recursive enumeration x with case y

Back

||

Front

logical operator or

Back

var x: Set<String> = ["x", "y", "z"]

Front

creating variable x of type Set<String> initialized by an array literal with items "x", "y" , "z"

Back

x.insert(contentsOf: "xyz", at: x.startIndex)

Front

insert String "xyz" into a string x at the startIndex

Back