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
struct ObjectToConstruct { | |
let propertyOne: String? | |
let propertyTwo: Array<String>? | |
let propertyThree: Bool? | |
} | |
class ConstructBuilder { | |
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
//MARK: Abstract factory pattern | |
protocol AbstractProductA{ | |
func display() -> String | |
} | |
protocol AbstractProductB{ | |
func display() -> String |
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
//MARK: From https://mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html | |
import UIKit | |
//MARK: TYPE VARIANCE LESSON | |
//First we explore supertypes and subtypes | |
class Thing {} | |
class Vehicle: Thing {} |
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 UIKit | |
class Thing { | |
var name: String | |
var quantity: Int | |
init(name: String, quantity: Int){ | |
self.name = name |
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
//Exercises from https://www.pointfree.co/episodes/ep9-algebraic-data-types-exponents | |
import UIKit | |
enum Either<A,B> { | |
case left(A) | |
case right(B) | |
} | |
struct Pair<A,B> { |