The 'with' function in Kotlin allows you to execute a block of code within the context of an object. This is particularly useful for performing multiple operations on the same object without repeatedly referencing it. It enhances code readability and reduces redundancy.
val person = Person("John", 30)
with(person) {
println("Name: $name")
println("Age: $age")
// Additional operations can be performed here
}