morganbovi
04/24/2018, 4:56 PMvariable?.run{ }
== run this block if this thing is not null? correct?rook
04/24/2018, 6:27 PMvariable
as it’s context.
Lets say variable
contains some member function foo, and we’ll look at how all the neato blocks return:
val result = resultvariable?.run{
foo()
}
result == Unit
val result = variable?.apply{
foo()
}
result == variable
val result = variable?.let{
it.foo()
}
result == result of foo()
val result = variable?.also{
it.foo()
}
result == Unit
Hope this helps!