- The Basics: assertions (only in dev), preconditions (in dev and prod)
- Basic Operators (+, -, *, /, ==, >=, <=, ||, &&, ..., ..<)
- Strings and Characters
- Colleciton Types (Array, Sets, Dictionaries, KeyValuePairs)
- Control Flow
- Functions: defer, inout, subscript
- Closures: callbacks
- Enumerations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"results": [ | |
{ | |
"gender": "male", | |
"name": { | |
"title": "Monsieur", | |
"first": "Alfonso", | |
"last": "Rolland" | |
}, | |
"location": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.swift | |
// Stack | |
// | |
// Created by Alex Paul on 10/6/20. | |
// | |
import Foundation | |
struct Stack<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Created by Alex Paul on 9/16/20. | |
// Copyright © 2020 Alex Paul. All rights reserved. | |
// | |
import Foundation | |
// Reverse a singly linked list. | |
class Node { | |
var value: Int |
import Foundation
func add(a: Int, b: Int) -> Int {
return a + b
}
while true {
print("enter a")
let a = Int(readLine() ?? "") ?? 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Making sections for a 2D array to be used in a CollectionView or TableView. [Fellow] => [[Fellow]] | |
import Foundation | |
struct Fellow { | |
let name: String | |
let cohort: String | |
static func allFellows() -> [Fellow] { | |
return [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Combine | |
let publisherArr = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0].publisher | |
// publisher is of type Publishers.Sequence<[Double], Never> | |
// the generic type here takes two arguments <Output, Failure> | |
// in this case the our publisherArr will "Never" fail. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
class Event { | |
@Published var calendarYear = 2020 // initial value | |
} | |
let event = Event() // new instance of Event | |
event.$calendarYear |