Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Concers
Last active January 12, 2021 13:15
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 Concers/01fd758f4d253b9abe7a2c88a481b484 to your computer and use it in GitHub Desktop.
Save Concers/01fd758f4d253b9abe7a2c88a481b484 to your computer and use it in GitHub Desktop.
class FavoriteAuthor(_name: String, _lastname: String, _age: Int) {
var name = _name
var lastname = _lastname
var age: Int? = _age
get() {
return if (field!! > 0) field else null
}
}
val favoriteauthor = FavoriteAuthor("Franz","Kafka",-1)
println("Favorite Author: ${favoriteauthor.name} ${favoriteauthor.lastname} ${favoriteauthor.age}")
// Favorite Author: Franz Kafka null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment