Skip to content

Instantly share code, notes, and snippets.

@magdamiu
Last active August 21, 2021 12:36
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 magdamiu/7092e26570e820e7bf30eda0ed8f6493 to your computer and use it in GitHub Desktop.
Save magdamiu/7092e26570e820e7bf30eda0ed8f6493 to your computer and use it in GitHub Desktop.
Clean Code with Kotlin by Magda Miu - Meaningful names 2 - Unclean Code
class Book(val title: String?, val publishYear: Int?)
fun displayBookDetails(book: Book) {
val title = book.title
if (title == null)
throw IllegalArgumentException("Title required")
val publishYear = book.publishYear
if (publishYear == null) return
println("$title: $publishYear")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment