var = programmingLanguage = "swift"
More readable than just programminglanguage
Back
Example of an array
Front
var todo = ["Learn Swift", "Build App", "Deploy App"]
println(todo.count)
Back
Binary? True or false (Boolean)
Front
Binary means that you can have either 1 or 0.
A true or a false statement is a boolean.
(var jonasIsInWVU = true)
Back
Swift and numbers
Front
Swift will assume that when you type a number without a decimal it is an Int and vise versa. You can also specify a number to a Double, Float, or Int if you want to.
(var version: Double = 1.0 )
(var version = 1.0)
Back
Variable (var)
Front
It can be modified!
Back
Option and Clicking the function will explain what the function does.
Front
Explains what the function does.
Back
Example of Appending an Array
Front
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo.append ("Debug App")
todo.append ("Fix Bugs")
let item = todo.removeAtIndex(2)
Back
What is the answer:
let z = 5 + 5 - 5 * 2
Front
Multiplication, Division, Remainder has a higher priority.
Plus and minus has lower priority.
Everything moves left to right.
Answer: 0
.insert will insert a new variable into the array in a specific area. You specify where by you writing after the atIndex:
Back
Float
Front
A number that can have a decimal point.
It can have up to 7 decimal digits
Back
string interperlation
Front
println("Good morning \ (friendOfJonas)")
This tells the computer that the input of println has a constant in it that is (friendOfJonas)
\ = makes it constant
Back
How to count the number of variable in an Array?
Front
nameofvariable.count ----> numberofarrays
Back
10 + 5
Front
10 and 5 : Operand
+ : operator
Back
var str = "Hello, playground"
Front
var = is something to store "Hello, playground"
str = Is a variable and is the box's name that stores the value "Hello, playground".
You only need to declare a variable once. Meaning if you want to change it. You can change it by doing
(str = "playground")
Back
append function?
Front
todo.append ("Conquer Swift")
- This adds "Conquer Swift" to the todo array.
Back
todo.removeLast()
Front
It will tell us which item it removed in the array.
Back
Int (integer)
Front
A number that does not have a decimal point
Back
To remove a key from a value in a Dictionary
Front
countries.removeValueForKey("CA")
var countries = [ "BE" : "Belgium", "FR" : "France", "US" : "United States of America" ]
Back
Updating a key is simple too in a Dictionary
Front
countries ["US"] = "United States of America"
var countries = [ "CA" : "Canada", "BE" : "Belgium", "FR" : "France", "US" : "United States of America" ]
Back
(print) function?
Front
print is a FUNCTION not a command.
Can take a string in quotes and a name of a variable:
print("Hello there!")
print(greeting)
Back
Double
Front
A number that can have a decimal point.
It can have up to 15 decimal digits
Back
Immutable string
Front
unmodifiable string
(let poop = "diarrhea")
Back
let areaInMeters = Double(area) / 10.764
Front
Double(area) : makes it so that the variable that you input is in decimals
Back
println V.S. print
Front
print command just prints whatever you give it.
println makes the next print start on a brand new line.
Back
Concatenation
Front
Adding two or more stings together
(let gross = "diarrhea" + poop)
Back
Console?
Front
Can print something within your program.
To print something you need to type the command.
[ print("Hello there!") ]
Back
unicode
Front
Industry Standard for characters
Back
Mutable string
Front
modifiable string
(var poop = "diarrhea")
Back
todo.removeAtIndex(1)
Front
This will remove the 2nd variable in the array's index.
var todo: [String] = ["Apple", "Orange", "Lemon"]
var todo: [Double] = [6.1, 6.2, 6.3]
etc...
Back
Adding a new key value to the Dictionary
Front
countries["US"] = "United States"
It will then add this to the array.
var countries = [ "CA" : "Canada", "BE" : "Belgium", "FR" : "France", "US" : "United States" ]
Back
Dictionary in Swift
Front
var countries = [ "CA" : "Canada", "BE" : "Belgium", "FR" : "France" ]
countries ["CA"] -----> This will give me "Some Canada"
var todo: [Double] = [6.1, 6.2, 6.3]
todo += [6.4]
or
var todo: [Double] = [6.1, 6.2, 6.3]
todo = todo + [6.4]
Back
Editing a Variable in an Array.
Front
You can only do this if the array is specified as Var.
var todo = ["Learn Swift", "Build App", "Deploy App"]
todo[2] = "Undeploy App"
- This will update the "Deploy App" in todo to "Undeploy App"
Back
How to specify a variable type? (implicate type)
Sting, number, or number with decimals?
Front
let word : String = "Hello"
Back
! What does that mean?
Front
NOT operator
let off = !on : False
Back
IDE
Front
Integrated Development Enviroment
Back
Constant (let)
Front
it can not be modified!
Back
\t
Front
= after this the words are printed on a new line.
\t = tabs the result.