Created
October 25, 2016 08:43
-
-
Save sliskiCode/b42a582ac4807ee005aaa5f1abf68b40 to your computer and use it in GitHub Desktop.
Builders in Kotlin. Gist 5
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
val withTitle: Boolean = true | |
// More concise | |
Person.create { | |
name { if (withTitle) "Mr. Peter" else "Peter" } | |
surname { "Slesarew" } | |
age { 28 } | |
} | |
// It does not even compile | |
Person(if (withTitle) name = "Mr. Peter" else name = "Peter", | |
surname = "Slesarew", | |
age = 28) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment