class Foo() {
private lateinit var myFile: File
fun bar(path: String?) {path?.let { myFile = File(it) }}
fun bar2() {myFile.whateverMethod()// May crash since I don't know whether myFile has been initialized}}
val chosenFile = SimpleObjectProperty<File?>val button: Button
// Disables the button if chosenFile.get() is nullbutton.disableProperty.bind(chosenFile.isNull())
class Foo() {
private lateinit var myFile: File
fun isFileInitialised() = ::file.isInitialized}
// in another classclass Bar() {
val foo = Foo()
if(foo.isFileInitialised()) // this should work}