Skip to content

Instantly share code, notes, and snippets.

View akatkov7's full-sized avatar

Andriy Katkov akatkov7

  • Riff Digital
  • Seattle, WA
View GitHub Profile
@akatkov7
akatkov7 / ApplyAndWith.swift
Created March 26, 2018 18:25
Adds Kotlin-esque apply/with to Swift
import Foundation
protocol ApplyProtocol { }
extension NSObject: ApplyProtocol { }
extension ApplyProtocol {
@discardableResult func apply(closure: (Self) -> Void) -> Self {
closure(self)
return self