[英]In TornadoFX, how can I select a deeply-nested property on an nullable property of an ItemViewModel?
TornadoFX has an select
function that is used to access a property within a property. TornadoFX具有一个
select
函数,该函数用于访问属性内的属性。 For example, the usage would be: 例如,用法为:
textfield(viewModel.customerProperty.select(Customer::nameProperty))
And that works fine, however, in case that the customerProperty
's value is nullable ( Customer?
), select
doesn't work, because it expects non-null object to "select" from. 而且,这很好用,但是如果
customerProperty
的值可以为null( Customer?
),则select
不起作用,因为它希望非null对象从中进行“选择”。
In case that the Property
has nullable
value, how can select
be used on it? 如果该
Property
具有nullable
值,如何在其上使用select
?
You don't need to declare the type as nullable even though the property can contain null. 即使属性可以包含null,也不需要将类型声明为可为null。 Simply change the type of the property and you should be good.
只需更改属性的类型,就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.