Created
November 7, 2020 10:17
-
-
Save MojtabaHs/71dee67d75a0bbe11a763e7fc67c8cd6 to your computer and use it in GitHub Desktop.
A simple operator to modify the object right at the initialization part.
This file contains hidden or 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
infix operator .. | |
@inline(__always) | |
func ..<T: EmptyInitializable>(lhs: T, rhs: (T)->()) -> T { | |
rhs(lhs) | |
return lhs | |
} | |
/* Example: | |
let myLabel = UILabel() .. { | |
$0.textColor = .red | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment