Created
January 13, 2017 10:41
-
-
Save maxsokolov/1cbb007e785347102e20273050fd745d to your computer and use it in GitHub Desktop.
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
public func with<T>(_ item: inout T, action: (inout T) -> Void) { | |
action(&item) | |
} | |
public func with<T>(_ item: T, action: (T) -> Void) { | |
action(item) | |
} | |
public func with<T: AnyObject>(_ item: T, action: (T) -> Void) { | |
action(item) | |
} | |
/** | |
* Instead of: | |
* | |
* attributes.frame.size = CGSize(width: size.width + 10, height: 23) | |
* attributes.frame.left = attributes.iconViewFrame.right + 8 | |
* attributes.frame.top = 8 | |
* | |
* use: | |
* | |
* with(&attributes.frame) { | |
* $0.size = CGSize(width: size.width + 10, height: 23) | |
* $0.left = attributes.iconViewFrame.right + 8 | |
* $0.top = 8 | |
* } | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment