Would you go with :one: : ``` nullableValue = Null...
# codingconventions
t
Would you go with 1️⃣ :
Copy code
nullableValue = NullableValue(1, 2, 3)
nullableValue?.someProperty = 4
or 2️⃣ :
Copy code
nullableValue = NullableValue(1, 2, 3).apply {
    someProperty = 4
}
where
NullableValue
constructor has a lot of params.
2️⃣ 17
d
Isn't 2 supposed to be
?.apply
?
t
Nope, in this case
NullableValue()
is a constructor of object. Example is a little misleading (
d
So why does 1 have
?.
? Could you show the implementation?
t
nullableValue
defined as class property:
var nullableValue: NullableValue? = null
b
I personally opt for
apply
when you’re wanting to call additional methods/properties immediately following the constructor. One potential advantage also being you now have context to the full type returned by the method instead of relying on the potentially more generic property being set to