Skip to content

Instantly share code, notes, and snippets.

@kimar
kimar / Applicable.swift
Last active January 10, 2020 03:41
Implement `apply` on NSObject (and other types)
import Foundation
protocol Applicable {}
extension NSObject: Applicable {}
extension Applicable {
@discardableResult
func apply(_ closure: (Self) -> Void) -> Self {
closure(self)
return self