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
// I wanted an equivalent to Ruby's `tap` (http://ruby-doc.org/core-2.3.0/Object.html#method-i-tap) in Swift which I could mix into any type to tap into method chains. | |
// Define the interface we want to provide as a protocol | |
private protocol Tap { | |
func tap(block: (Self) -> Void) -> Self | |
} | |
// Extend the `Tap` protocol with a default implementation | |
private extension Tap { | |
func tap(block: (Self) -> Void) -> Self { |
OlderNewer