This file contains 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 | |
extension UICollectionViewCompositionalLayout { | |
static func waterfall( | |
columnCount: Int, | |
interItemSpacing: CGFloat = 0, | |
lineSpacing: CGFloat = 0, | |
itemCountProvider: @escaping (Int) -> Int, | |
itemSizeProvider: @escaping (IndexPath) -> CGSize, | |
sectionConfigurator: @escaping (inout NSCollectionLayoutSection) -> Void = { _ in }, |
This file contains 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 | |
extension AsyncStream { | |
init( | |
_ elementType: Element.Type = Element.self, | |
bufferingPolicy limit: AsyncStream<Element>.Continuation.BufferingPolicy = .unbounded, | |
_ build: @escaping (AsyncStream<Element>.Continuation) async -> Void | |
) { | |
self = AsyncStream(elementType, bufferingPolicy: limit) { continuation in | |
Task { await build(continuation) } |
This file contains 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 SwiftUI | |
// MARK: DeepLink | |
final class DeepLink { | |
private let url: URL | |
private lazy var pathComponents = self.paths | |
private var paths: [String] { | |
[self.url.host].compact() + self.url.pathComponents.dropFirst() |
This file contains 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
// poor arrow function expression implementation like javascript's using infix operator and closure | |
precedencegroup ArrowFunctionExpressionPrecedence { | |
associativity: left | |
higherThan: BitwiseShiftPrecedence | |
} | |
infix operator =>: ArrowFunctionExpressionPrecedence | |
infix operator ==>: ArrowFunctionExpressionPrecedence |
This file contains 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
var greeting: String? = "Hello, playground" | |
class Wrapper<T> { | |
var value: T | |
init(initialValue: T) { | |
self.value = initialValue | |
} | |
func transform<V>(_ transform: (T) -> V) -> V { |
This file contains 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
[ | |
[ | |
{ | |
"a": 7 | |
}, | |
"", | |
"", | |
{ | |
"x": 0.25, | |
"a": 0 |
This file contains 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 NotePage { | |
var title: String | |
var contents: String | |
} | |
class NoteCover { | |
var page: NotePage | |
init(page: NotePage) { | |
self.page = page |
This file contains 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
protocol Enumable { | |
static func integerHolder(_: Int) -> Self | |
} | |
// SE-0280 | |
enum Value: Enumable { | |
case integerHolder(Int) | |
} | |
let someValue = Value.integerHolder(1) |