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