``` MyObj ( var1 ?: return null, var2 ?: return nu...
# announcements
i
Copy code
MyObj ( var1 ?: return null, var2 ?: return null)
not sure that's ideal though
s
why not just
Copy code
fun Foo.foo(): MyObj? =
  if (var1 != null && var2 != null) MyObj(var1, var2) else null
i
If
var1
and
var2
are really vars here, they won't be smartcasted.
s
true, for that var1 and var2 should be assigned to local variables.
i
they are `val`s
MyObj ( var1 ?: return null, var2 ?: return null)
still seems to be the less verbose option