Norg
08/01/2018, 5:32 PMattrs.caption = state.toBeDeleted?.asDynamic()["name"].toString()
I'm expecting that if state.toBeDeleted
is null
, the rest of row will not be invoked, and null
will be the value of the whole expression. But this row is compiled into:
$receiver.attrs.caption = ((tmp$ = this$Content.state.toBeDeleted) != null ? tmp$ : null)['name'].toString();
And the result is Cannot read property 'name' of null
. Am I misunderstanding something?Norg
08/01/2018, 5:38 PMnull
values?anton.bannykh
08/02/2018, 11:29 AMattrs.caption = state.toBeDeleted.asDynamic()?.`name`?.toString()
anton.bannykh
08/02/2018, 11:32 AMasDynamic
is an extension function to Any?
, so it will work with null
receiveranton.bannykh
08/02/2018, 11:34 AMdynamic
is already nullable, so null?.asDynamic()
should be the same as null.asDynamic()
. Both expressions have type dynamic
. Which is why the compiler didn't complain about the ["name"]
being applied to a nullable receiverNorg
08/02/2018, 12:58 PM