Last active
October 6, 2021 08:33
-
-
Save jegnux/44a00423ca6f367d25f08df37db59759 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
prefix operator .. | |
infix operator ..: MultiplicationPrecedence | |
/* | |
Custom operator that lets you configure an instance inline | |
```swift | |
let label = UILabel()..{ | |
$0.numberOfLines = 0 | |
$0.textColor = .systemRed | |
} | |
``` | |
*/ | |
@discardableResult | |
public func .. <T>(object: T, configuration: (inout T) -> Void) -> T { | |
var object = object | |
configuration(&object) | |
return object | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment