Skip to content

Instantly share code, notes, and snippets.

@cioccarellia
Created March 28, 2021 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cioccarellia/94e249c965999b50c811d6887970d4fe to your computer and use it in GitHub Desktop.
Save cioccarellia/94e249c965999b50c811d6887970d4fe to your computer and use it in GitHub Desktop.
// Standard
val bob = Person("Bob", 19, "Texas")
println(bob)
bob.moveTo("Florida")
bob.incrementAge()
bob.alias = "Bravo"
println(bob)
// Using apply
val alice = Person("Alice", 19, "Italy").apply {
println(this)
moveTo("France")
incrementAge()
alias = "Alpha"
println(this)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment