Tomas Kormanak
11/12/2021, 12:13 PMwith
which is ignoring return value and returns Unit
?
Something like this:
public inline fun <T> with(receiver: T, block: T.() -> Unit): Unit {
receiver.block()
}
Or any better idea how to avoid explicitly returning Unit in this case:
fun process(data: Data) = with(data) {
///doSomething
Unit
}
Rob Elliot
11/12/2021, 1:21 PMfun process(data: Data) {
data.apply {
// doSomething
}
}
It’ll return Data
rather than Unit
but you can just discard that.val person = Person().apply {
name = ""
dateOfBirth = TODO()
...
}
)Vampire
11/12/2021, 1:36 PMfun process(data: Data): Unit = with(data) {
// ...
}
fun process(data: Data) {
with(data) {
// ...
}
}
Joffrey
11/12/2021, 1:40 PMUnit
(instead of using an expression with =
)Ruckus
11/12/2021, 3:44 PMfun Data.process() {
///doSomething
}