Understanding kotlin's `apply` and `with` functions?

In Kotlin, standard library functions like `apply` and `with` can be used to simplify operations on objects. These functions make the code more concise:


  data class Person(var name: String, var age: Int)
  val person = Person("John", 30)
  person.apply {
      age = 31
  }
  

Beginner's Guide to Kotlin