https://speakerdeck.com/gwengrid/keep-calm-and-type-erase-on
Step-By-Step, writing a type-erased wrapper class by Hector Matos
Why?! No type parameters on generic protocols pt 1 pt 2 by Russ Bishop
import Foundation | |
import PlaygroundSupport | |
import SwiftUI | |
struct Content: View { | |
var body: some View { | |
Text("👋🏻, 🌍!") | |
} | |
} |
extension UICollectionViewFlowLayout { | |
typealias DelegateMethod<Key, Value> = ((UICollectionView, UICollectionViewLayout, Key) -> Value) | |
private var delegate: UICollectionViewDelegateFlowLayout? { | |
return collectionView?.delegate as? UICollectionViewDelegateFlowLayout | |
} | |
func retrieve<Key, Value>( |
// Douglas Hill, February 2018 | |
import Foundation | |
/// Returns a localised string with the key as an enum case so the compiler checks it exists. | |
/// The enum should be automatically generated using UpdateLocalisedStringKeys.swift. | |
public func localisedString(_ key: LocalisedStringKey) -> String { | |
return Bundle.main.localizedString(forKey: key.rawValue, value: nil, table: nil) | |
} |
extension UILayoutPriority: ExpressibleByFloatLiteral, ExpressibleByIntegerLiteral { | |
public init(floatLiteral value: Float) { | |
self.init(rawValue: value) | |
} | |
public init(integerLiteral value: Int) { | |
self.init(rawValue: Float(value)) | |
} | |
public static func +(lhs: UILayoutPriority, rhs: UILayoutPriority) -> UILayoutPriority { |
https://speakerdeck.com/gwengrid/keep-calm-and-type-erase-on
Step-By-Step, writing a type-erased wrapper class by Hector Matos
Why?! No type parameters on generic protocols pt 1 pt 2 by Russ Bishop
%% Copyright 2020 Alexander Yakushev | |
% | |
% This work may be distributed and/or modified under the | |
% conditions of the LaTeX Project Public License, either version 1.3 | |
% of this license or (at your option) any later version. | |
% The latest version of this license is in | |
% http://www.latex-project.org/lppl.txt | |
% and version 1.3 or later is part of all distributions of LaTeX | |
% version 2005/12/01 or later. | |
% |
#Every Single Option Under The Sun
/* | |
ericasadun.com | |
Playground Support for NIB-based interaction: Add to playground's Sources folder | |
*/ | |
import Cocoa | |
import XCPlayground |
// Note: This must be used in an Xcode project that contains a bridging header | |
// that includes <asl.h> | |
import Foundation | |
/// Provides high-level methods to access the raw data in | |
/// an ASL message. | |
struct SystemLogEntry { | |
/// Key-value pairs read from ASL message | |
let data: [String : String] |
import Foundation | |
func genericFizzBuzz<T> (number:T, tests:Array<(T)->String?>) -> String { | |
// Run each of the defined test replacements | |
let out = tests.map { t in t(number) } | |
// convert the nil's to empty strings | |
.map { v in v ?? "" } | |
// Concatenate all the replacements together | |
.reduce("", combine: +) |