mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-16 11:45:04 +02:00
This commit is contained in:
@@ -189,13 +189,13 @@ fun helloWorld(val name : String) {
|
||||
|
||||
// The "with" function is similar to the JavaScript "with" statement.
|
||||
data class MutableDataClassExample (var x: Int, var y: Int, var z: Int)
|
||||
val fooMutableDate = MutableDataClassExample(7, 4, 9)
|
||||
with (fooMutableDate) {
|
||||
val fooMutableData = MutableDataClassExample(7, 4, 9)
|
||||
with (fooMutableData) {
|
||||
x -= 2
|
||||
y += 2
|
||||
z--
|
||||
}
|
||||
println(fooMutableDate) // => MutableDataClassExample(x=5, y=6, z=8)
|
||||
println(fooMutableData) // => MutableDataClassExample(x=5, y=6, z=8)
|
||||
|
||||
/*
|
||||
We can create a list using the "listOf" function.
|
||||
|
Reference in New Issue
Block a user