You are on page 1of 1

Types Variables Strings

Int 1, 25, 589, 30_000 let iAmAConstant : Int = 42 var combi = "\(string1)
Float 1.6, 6.89, 4.6789, 3.14159 var iAmAVariable : Int = 23 + \(string2)"
Double 3.1415925359 later... iAmAVariable = 46 let numberString = "2"
Bool true, false var inferredVariable = "I'm a string" var integer
String "Angela", "Philipp" var optionalString:String? = nil =numberString.toInt

Classes Methods Arrays + Dict


let one = "Uno"
class myClass:someSuperClass { func myMethod() -> Bool {
let two = "Dos"
var myProperty:Int? return true } var array : [String]
override init() { func methodWithParam (a:Int, b:int) { = ["one", "two"]
a+b array.append("Tres")
myProperty = 12
print("two = \(array[1]")
} //methods } }
var dict :
If + For Loops Switch Dictionary [String: Int] =
["One": 1, "Two": 2]
if someCondition == true { //do x switch someVariable {
dict["Two"] = "Dos"
} else { //do y } case 1: "Hello" dict["One"] = nil //=delete
for var i = 0 ; i < 4 ; i++ { //do smthin} case 2: "Good Bye" for (string, number) in dict{ }

for i in 0...4 { //do something else } default: "Nothing" }


for i in 0..<4 {//do another thing }

You might also like