Skip to content

Instantly share code, notes, and snippets.

View Agarunov's full-sized avatar

Anton Agarunov Agarunov

View GitHub Profile
class Department { }
protocol Employee {
// warning: 'weak' should not be applied to a property declaration in a protocol
// and will be disallowed in future versions
weak var department: Department? { get }
}
struct Point: Hashable {
let x: Float
let y: Float
}
let p1 = Point(x: 0.0, y: 0.0)
let p2 = Point(x: 1.0, y: 1.0)
p1 == p2 // false
@Agarunov
Agarunov / type_erasure.swift
Last active November 10, 2021 15:12
Swift Type Erasure example
//: Playground - noun: a place where people can play
protocol ObjectMapper {
associatedtype SourceType
associatedtype ResultType
func map(_ object: SourceType) -> ResultType