Skip to content

Instantly share code, notes, and snippets.

@peterkos
Created October 15, 2018 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterkos/8e0ed2319e9c614d1e5abfe9e39986b0 to your computer and use it in GitHub Desktop.
Save peterkos/8e0ed2319e9c614d1e5abfe9e39986b0 to your computer and use it in GitHub Desktop.
Code written on Week 0 of the iOS Development Workshop, Autumn 2018, w/ Dubstech
import UIKit
// var -- Variable (value can change)
// let -- Constant (value cannot change)
var str = "Hello, playground"
str = "My New String"
var myNum = 5
// The line below gives an error!
//myNum = "a string"
var anotherNum: Double = 5.0
let anotherOtherNum: String = "Text"
// jaosdfjl;askfjas;dlkfja;lfijawelfkj
/*
alsdjfladskf
alskdfa;sklfjasdf
jsalkfjasdfk
*/
let theRealVIP = "Bill Nye"
if theRealVIP == "Bill Nye" {
// print("BILL BILL BILL BILL BILL BILL")
} else {
// print("😭 ")
}
let 😀 = "happy"
print(😀)
// Loops
/*
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
*/
// 2 "range operators"
// 0...10 0 1 2 3 4 5 6 7 8 9 10
// 0..<10 0 1 2 3 4 5 6 7 8 9
for i in (0..<10).reversed() {
// print(i, terminator: "")
}
//print("\nafter for loop")
// Arrays
var groceries = ["Banana", "Apple", "Pear"]
var amountOfSodas: [Int] = [1, 2, 3, 4, 5]
for item in groceries {
print(item)
}
groceries.append("Apple")
print(groceries.count)
// String Interpolation
let name = "Peter"
// System.out.println("Hello, " + name);
print("Hello, \(name)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment