https://kotlinlang.org logo
Title
j

Jgafner

10/14/2020, 8:21 PM
Hi Can someone please explain me this code ?
fun aFun() : ObjectA?{
val (side,line) = when(someData){
      is TypeA -> thread.position?.let { diffData.linesMapper.findFileLocation(it) } ?: return null
      is TypeB -> ... ?: return null
}

return ObjectA(side,line)
when ObjectA constructor is expecting null safe type of side and line. in case of is TypeA happen and it return null what will be the values in side and line ? tnx
n

nanodeath

10/14/2020, 8:22 PM
the
return null
lines return from the entire method, not just the
when
expression
j

Jgafner

10/14/2020, 8:22 PM
tnx!!!
👍 1